Browse Source

OAaccount 插入

dongql 7 years ago
parent
commit
f3aaa260d5

+ 7 - 0
oa_service/oa_service.iml

@@ -11,6 +11,13 @@
     </content>
     <orderEntry type="inheritedJdk" />
     <orderEntry type="sourceFolder" forTests="false" />
+    <orderEntry type="library" name="Maven: net.sourceforge.nekohtml:nekohtml:1.9.22" level="project" />
+    <orderEntry type="library" name="Maven: xerces:xercesImpl:2.11.0" level="project" />
+    <orderEntry type="library" name="Maven: xml-apis:xml-apis:1.4.01" level="project" />
+    <orderEntry type="library" name="Maven: org.apache.shiro:shiro-spring:1.3.2" level="project" />
+    <orderEntry type="library" name="Maven: org.apache.shiro:shiro-core:1.3.2" level="project" />
+    <orderEntry type="library" name="Maven: commons-beanutils:commons-beanutils:1.9.3" level="project" />
+    <orderEntry type="library" name="Maven: org.apache.shiro:shiro-web:1.3.2" level="project" />
     <orderEntry type="library" name="Maven: net.sourceforge.jexcelapi:jxl:2.6.12" level="project" />
     <orderEntry type="library" name="Maven: log4j:log4j:1.2.14" level="project" />
     <orderEntry type="library" name="Maven: com.bjlt.spider:spider-rpc:0.0.4-SNAPSHOT" level="project" />

+ 8 - 1
oa_service/src/main/java/com/bjlt/spider/entity/OaAccount.java

@@ -1,10 +1,13 @@
 package com.bjlt.spider.entity;
 
+import com.fasterxml.jackson.annotation.JsonFormat;
 import lombok.AllArgsConstructor;
 import lombok.Builder;
 import lombok.Data;
 import lombok.NoArgsConstructor;
 
+import java.util.Date;
+
 /**
  * oa_account
  */
@@ -77,7 +80,11 @@ public class OaAccount  extends Page {
 	/**
 	 积分账户最后更新日期
 	 */
-	private String lastUpdateTime;
+	@JsonFormat(
+			pattern = "yyyy-MM-dd HH:mm:ss",
+			timezone = "GMT+8"
+	)
+	private Date lastUpdateTime;
 	
 	/**
 	 积分余额

+ 20 - 0
oa_service/src/main/java/com/bjlt/spider/table/controller/OaAccountController.java

@@ -2,6 +2,7 @@ package com.bjlt.spider.table.controller;
 
 import com.bjlt.spider.entity.OaAccount;
 import com.bjlt.spider.table.service.OaAccountService;
+import com.bjlt.spider.util.RespEntity;
 import com.bjlt.spider.utils.LayuiTableRespEntity;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -10,6 +11,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestMethod;
 import org.springframework.web.bind.annotation.ResponseBody;
 
+import java.util.Date;
 import java.util.List;
 
 @RequestMapping(value = "/oaAccount")
@@ -40,4 +42,22 @@ public class OaAccountController {
         layuiTableRespEntity.setRel(true);
         return layuiTableRespEntity;
     }
+
+    /**
+     * 插入
+     * @param oaAccount
+     */
+    @RequestMapping(value = "/add" ,method = RequestMethod.POST)
+    @ResponseBody
+    public RespEntity insertSelective(OaAccount oaAccount){
+
+        try {
+            oaAccount.setLastUpdateTime(new Date());
+            oaAccountService.insertSelective(oaAccount);
+            return RespEntity.success(oaAccount);
+        } catch (Exception e) {
+            return RespEntity.success("false");
+        }
+
+    }
 }

+ 2 - 0
oa_service/src/main/java/com/bjlt/spider/table/dao/OaAccountDao.java

@@ -6,4 +6,6 @@ import java.util.List;
 
 public interface OaAccountDao {
     List<OaAccount> listPageOaAccount(OaAccount oaAccount);
+
+    void insertSelective(OaAccount oaAccount);
 }

+ 22 - 0
oa_service/src/main/java/com/bjlt/spider/table/dao/impl/OaAccountDaoImpl.java

@@ -21,6 +21,11 @@ public class OaAccountDaoImpl implements OaAccountDao {
     @Autowired
     JdbcTemplate jdbcTemplate;
 
+    /**
+     * 分页查询
+     * @param oaAccount
+     * @return
+     */
     @Override
     public List<OaAccount> listPageOaAccount(OaAccount oaAccount) {
         StringBuffer stringBuffer = new StringBuffer();
@@ -37,6 +42,23 @@ public class OaAccountDaoImpl implements OaAccountDao {
         return list;
     }
 
+    /**
+     * 插入
+     * @param oaAccount
+     */
+    @Override
+    public void insertSelective(OaAccount oaAccount) {
+        StringBuffer stringBuffer = new StringBuffer();
+        stringBuffer.append("insert into oa_account (");
+        Map<String,Object> map = map(oaAccount);
+        stringBuffer.append(String.join(",",map.keySet()));
+        stringBuffer.append(") values (");
+        List<String> wenhao = map.keySet().stream().map(t -> "?").collect(Collectors.toList());
+        stringBuffer.append(String.join(",",wenhao));
+        stringBuffer.append(")");
+        jdbcTemplate.update(stringBuffer.toString(),map.values().toArray());
+    }
+
     private Integer count(String where, Object[] objects) {
         String sql = "select count(*) from oa_account " + where;
         return jdbcTemplate.queryForObject(sql,Integer.class,objects);

+ 2 - 0
oa_service/src/main/java/com/bjlt/spider/table/service/OaAccountService.java

@@ -6,4 +6,6 @@ import java.util.List;
 
 public interface OaAccountService {
     List<OaAccount> listPageOaAccount(OaAccount oaAccount);
+
+    void insertSelective(OaAccount oaAccount);
 }

+ 5 - 0
oa_service/src/main/java/com/bjlt/spider/table/service/impl/OaAccountServiceImpl.java

@@ -18,4 +18,9 @@ public class OaAccountServiceImpl implements OaAccountService{
     public List<OaAccount> listPageOaAccount(OaAccount oaAccount) {
         return oaAccountDao.listPageOaAccount(oaAccount);
     }
+
+    @Override
+    public void insertSelective(OaAccount oaAccount) {
+        oaAccountDao.insertSelective(oaAccount);
+    }
 }