Browse Source

客户资料

zhoudw 7 years ago
parent
commit
8b82efffbf

+ 6 - 0
applications/commons/commons-dto/src/main/java/com/usoftchina/saas/commons/po/Status.java

@@ -11,6 +11,12 @@ public enum Status {
      */
     CLOSE("已关闭"),
 
+    /**
+     * 已开启
+     */
+    OPEN("已开启"),
+
+
     /**
      * 已审核
      */

+ 14 - 1
applications/document/document-server/src/main/java/com/usoftchina/saas/document/DocumentApplication.java

@@ -6,6 +6,8 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
 import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
 import org.springframework.cloud.openfeign.EnableFeignClients;
 import org.springframework.transaction.annotation.EnableTransactionManagement;
+import org.springframework.web.servlet.config.annotation.CorsRegistry;
+import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
 
 @SpringBootApplication
 @EnableEurekaClient
@@ -13,10 +15,21 @@ import org.springframework.transaction.annotation.EnableTransactionManagement;
 @EnableTransactionManagement
 @EnableFeignClients
 @MapperScan("com.usoftchina.saas.document.mapper")
-public class DocumentApplication {
+public class DocumentApplication extends WebMvcConfigurerAdapter {
 
     public static void main(String[] args) {
         SpringApplication.run(DocumentApplication.class);
     }
 
+
+    @Override
+    public void addCorsMappings(CorsRegistry registry) {
+
+        registry.addMapping("/**")
+                .allowCredentials(true)
+                .allowedHeaders("*")
+                .allowedOrigins("*")
+                .allowedMethods("*");
+    }
+
 }

+ 29 - 5
applications/document/document-server/src/main/java/com/usoftchina/saas/document/controller/CustomerController.java

@@ -66,12 +66,36 @@ public class CustomerController {
      * @param id
      * @return
      */
-    @GetMapping("/delete/{id}")
+    @PostMapping("/delete/{id}")
     public Result delete(@PathVariable("id") Long id) {
         customerService.delete(id);
         return Result.success();
     }
 
+    /**
+     * 客户联系人删除
+     *
+     * @param id
+     * @return
+     */
+    @PostMapping("/deletecontact/{id}")
+    public Result deletecontact(@PathVariable("id") Long id) {
+        customerService.deletecontact(id);
+        return Result.success();
+    }
+
+    /**
+     * 客户地址删除
+     *
+     * @param id
+     * @return
+     */
+    @PostMapping("/deleteaddress/{id}")
+    public Result deleteaddress(@PathVariable("id") Long id) {
+        customerService.deleteaddress(id);
+        return Result.success();
+    }
+
     /**
      * 采购订单批量删除
      *
@@ -92,8 +116,8 @@ public class CustomerController {
      */
     @PostMapping("/close/{id}")
     public Result close(@PathVariable(value = "id") long id){
-        customerService.close(id);
-        return Result.success();
+        DocBaseDTO close = customerService.close(id);
+        return Result.success(close);
     }
 
     /**
@@ -104,8 +128,8 @@ public class CustomerController {
      */
     @PostMapping("/open/{id}")
     public Result open(@PathVariable(value = "id") long id){
-        customerService.open(id);
-        return Result.success();
+        DocBaseDTO open = customerService.open(id);
+        return Result.success(open);
     }
 
 

+ 6 - 2
applications/document/document-server/src/main/java/com/usoftchina/saas/document/service/CustomerService.java

@@ -24,9 +24,13 @@ public interface CustomerService extends CommonBaseService<CustomerMapper, Custo
 
     void delete(Long id);
 
-    void close(long id);
+    DocBaseDTO close(long id);
 
-    void open(long id);
+    DocBaseDTO open(long id);
 
     void batchDelete(BatchDealBaseDTO baseDTOs);
+
+    void deletecontact(Long id);
+
+    void deleteaddress(Long id);
 }

+ 48 - 2
applications/document/document-server/src/main/java/com/usoftchina/saas/document/service/impl/CustomerServiceImpl.java

@@ -6,6 +6,8 @@ import com.usoftchina.saas.base.service.CommonBaseServiceImpl;
 import com.usoftchina.saas.commons.dto.BatchDealBaseDTO;
 import com.usoftchina.saas.commons.dto.DocBaseDTO;
 import com.usoftchina.saas.commons.dto.ListReqDTO;
+import com.usoftchina.saas.commons.exception.BizExceptionCode;
+import com.usoftchina.saas.commons.po.Status;
 import com.usoftchina.saas.context.BaseContextHolder;
 import com.usoftchina.saas.document.dto.CustomerDTO;
 import com.usoftchina.saas.document.dto.CustomerFormDTO;
@@ -238,13 +240,53 @@ public class CustomerServiceImpl extends CommonBaseServiceImpl<CustomerMapper, C
     }
 
     @Override
-    public void close(long id) {
+    public void deletecontact(Long id) {
+        customercontactMapper.deleteByPrimaryKey(id);
+        DocBaseDTO docBaseDTO = getBaseDTOById(id);
+        //日志
+//        messageLogService.deleteDetail(docBaseDTO);
+    }
 
+    @Override
+    public void deleteaddress(Long id) {
+        customeraddressMapper.deleteByPrimaryKey(id);
+        DocBaseDTO docBaseDTO = getBaseDTOById(id);
+        //日志
+//        messageLogService.deleteDetail(docBaseDTO);
     }
 
     @Override
-    public void open(long id) {
+    public DocBaseDTO close(long id) {
+        Customer customer = getMapper().selectByPrimaryKey(id);
+        if(Status.CLOSE.name().equals(customer.getCu_statuscode())){
+            throw new BizException(BizExceptionCode.BIZ_CLOSE);
+        }
+        customer = new Customer();
+        customer.setId(id);
+        customer.setCu_statuscode(Status.CLOSE.name());
+        customer.setCu_status(Status.CLOSE.getDisplay());
+        getMapper().updateByPrimaryKeySelective(customer);
+        DocBaseDTO docBaseDTO = getBaseDTOById(id);
+        //日志
+//        messageLogService.close(docBaseDTO);
+        return docBaseDTO;
+    }
 
+    @Override
+    public DocBaseDTO open(long id) {
+        Customer customer = getMapper().selectByPrimaryKey(id);
+        if(Status.OPEN.name().equals(customer.getCu_statuscode())){
+            throw new BizException(BizExceptionCode.BIZ_OPEN);
+        }
+        customer = new Customer();
+        customer.setId(id);
+        customer.setCu_statuscode(Status.OPEN.name());
+        customer.setCu_status(Status.OPEN.getDisplay());
+        getMapper().updateByPrimaryKeySelective(customer);
+        DocBaseDTO docBaseDTO = getBaseDTOById(id);
+        //日志
+//        messageLogService.close(docBaseDTO);
+        return docBaseDTO;
     }
 
     private List<CustomerList> getListByMode(ListReqDTO req) {
@@ -278,4 +320,8 @@ public class CustomerServiceImpl extends CommonBaseServiceImpl<CustomerMapper, C
         return baseDTO;
     }
 
+
+
+
+
 }

+ 7 - 7
applications/document/document-server/src/main/resources/mapper/BankinformationMapper.xml

@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8" ?>
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
 <mapper namespace="com.usoftchina.saas.document.mapper.BankinformationMapper" >
-  <resultMap id="BaseResultMap" type="com.usoftchina.saas.document.po.Bankinformation" >
+  <resultMap id="BaseResultMap" type="com.usoftchina.saas.document.entities.Bankinformation" >
     <id column="bk_id" property="bkId" jdbcType="INTEGER" />
     <result column="bk_bankcode" property="bkBankcode" jdbcType="VARCHAR" />
     <result column="bk_bankname" property="bkBankname" jdbcType="VARCHAR" />
@@ -24,7 +24,7 @@
     <result column="bk_text4" property="bkText4" jdbcType="VARCHAR" />
     <result column="bk_text5" property="bkText5" jdbcType="VARCHAR" />
   </resultMap>
-  <resultMap id="ResultMapWithBLOBs" type="com.usoftchina.saas.document.po.Bankinformation" extends="BaseResultMap" >
+  <resultMap id="ResultMapWithBLOBs" type="com.usoftchina.saas.document.entities.Bankinformation" extends="BaseResultMap" >
     <result column="bk_remark" property="bkRemark" jdbcType="LONGVARCHAR" />
   </resultMap>
   <sql id="Base_Column_List" >
@@ -47,7 +47,7 @@
     delete from bankinformation
     where bk_id = #{bkId,jdbcType=INTEGER}
   </delete>
-  <insert id="insert" parameterType="com.usoftchina.saas.document.po.Bankinformation" >
+  <insert id="insert" parameterType="com.usoftchina.saas.document.entities.Bankinformation" >
     insert into bankinformation (bk_id, bk_bankcode, bk_bankname, 
       bk_date, bk_type, bk_beginamount, 
       bk_thisamount, bk_status, bk_statuscode, 
@@ -65,7 +65,7 @@
       #{bkText3,jdbcType=VARCHAR}, #{bkText4,jdbcType=VARCHAR}, #{bkText5,jdbcType=VARCHAR}, 
       #{bkRemark,jdbcType=LONGVARCHAR})
   </insert>
-  <insert id="insertSelective" parameterType="com.usoftchina.saas.document.po.Bankinformation" >
+  <insert id="insertSelective" parameterType="com.usoftchina.saas.document.entities.Bankinformation" >
     insert into bankinformation
     <trim prefix="(" suffix=")" suffixOverrides="," >
       <if test="bkId != null" >
@@ -204,7 +204,7 @@
       </if>
     </trim>
   </insert>
-  <update id="updateByPrimaryKeySelective" parameterType="com.usoftchina.saas.document.po.Bankinformation" >
+  <update id="updateByPrimaryKeySelective" parameterType="com.usoftchina.saas.document.entities.Bankinformation" >
     update bankinformation
     <set >
       <if test="bkBankcode != null" >
@@ -273,7 +273,7 @@
     </set>
     where bk_id = #{bkId,jdbcType=INTEGER}
   </update>
-  <update id="updateByPrimaryKeyWithBLOBs" parameterType="com.usoftchina.saas.document.po.Bankinformation" >
+  <update id="updateByPrimaryKeyWithBLOBs" parameterType="com.usoftchina.saas.document.entities.Bankinformation" >
     update bankinformation
     set bk_bankcode = #{bkBankcode,jdbcType=VARCHAR},
       bk_bankname = #{bkBankname,jdbcType=VARCHAR},
@@ -298,7 +298,7 @@
       bk_remark = #{bkRemark,jdbcType=LONGVARCHAR}
     where bk_id = #{bkId,jdbcType=INTEGER}
   </update>
-  <update id="updateByPrimaryKey" parameterType="com.usoftchina.saas.document.po.Bankinformation" >
+  <update id="updateByPrimaryKey" parameterType="com.usoftchina.saas.document.entities.Bankinformation" >
     update bankinformation
     set bk_bankcode = #{bkBankcode,jdbcType=VARCHAR},
       bk_bankname = #{bkBankname,jdbcType=VARCHAR},

+ 1 - 1
applications/document/document-server/src/main/resources/mapper/CustomeraddressMapper.xml

@@ -33,7 +33,7 @@
     from customeraddress
     where ca_id = #{ca_id,jdbcType=INTEGER}
   </select>
-  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
+  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
     delete from customeraddress
     where ca_id = #{ca_id,jdbcType=INTEGER}
   </delete>

+ 1 - 1
applications/document/document-server/src/main/resources/mapper/CustomercontactMapper.xml

@@ -29,7 +29,7 @@
     from customercontact
     where cc_id = #{cc_id,jdbcType=INTEGER}
   </select>
-  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
+  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
     delete from customercontact
     where cc_id = #{cc_id,jdbcType=INTEGER}
   </delete>