Browse Source

无车优化,自有车接口返回

Administrator 2 years ago
parent
commit
6bf03fa0b4

+ 10 - 1
src/main/java/com/jkcredit/invoice/controller/business/CustomerController.java

@@ -91,7 +91,16 @@ public class CustomerController {
 
         return new RespR(customerService.findAllCustomers(page, customer));
     }
-
+    /**
+     * 修改客户状态
+     * @return 用户集合
+     */
+    @PostMapping("/updateCustomer")
+    @ApiOperation(value="更新用户", notes="更新用户")
+    @LoginRequired
+    public RespR updateCustomer(@RequestBody  Customer customer) {
+        return new RespR(customerService.updateCustomer(customer));
+    }
     /**
      * 分页查询客户
      *

+ 18 - 11
src/main/java/com/jkcredit/invoice/controller/user/UserController.java

@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.jkcredit.invoice.annotation.LoginRequired;
 import com.jkcredit.invoice.annotation.annotationdes.AuthenticationInterceptor;
 import com.jkcredit.invoice.model.entity.user.User;
+import com.jkcredit.invoice.model.vo.UserVo;
 import com.jkcredit.invoice.service.user.UserService;
 import com.jkcredit.invoice.util.Md5Util;
 import com.jkcredit.invoice.util.RespR;
@@ -43,7 +44,8 @@ public class UserController {
     @ApiImplicitParams({
             @ApiImplicitParam(name = "id", value = "用id", required = true, dataType = "Integer")
     })
-    public RespR user(@PathVariable @NotNull(message = "用户id不能为空")Integer id, User user) {
+    public RespR user(@PathVariable @NotNull(message = "用户id不能为空")Integer id, UserVo userVo) {
+        User user = userVo.getUserFromUserVo();
         if (!AuthenticationInterceptor.AUTH_ADMIN.equals(user.getRoleId()) && (user.getId().compareTo(id) != 0)) {
             return new RespR<>(false, "无权限");
         }
@@ -70,13 +72,14 @@ public class UserController {
     /**
      * 添加用户
      *
-     * @param user 用户信息
+     * @param userVo 用户信息
      * @return success/false
      */
     @PostMapping
     @ApiOperation(value = "新增用户详细信息", notes = "新增用户详细信息")
     @LoginRequired(role = AuthenticationInterceptor.AUTH_ADMIN)
-    public RespR user(@RequestBody @Validated User user) {
+    public RespR user(@RequestBody @Validated UserVo userVo) {
+        User user = userVo.getUserFromUserVo();
         user.setPassword(Md5Util.encrypt(user.getPassword()));
         User user1 = userService.selectUserByUserName(user.getUserName());
         if (null != user1) {
@@ -88,13 +91,14 @@ public class UserController {
     /**
      * 更新用户信息
      *
-     * @param user 用户信息
+     * @param userVo 用户信息
      * @return R
      */
     @PostMapping("/updateUser")
     @ApiOperation(value = "更新用户信息", notes = "更新用户信息")
     @LoginRequired(role = AuthenticationInterceptor.AUTH_ADMIN)
-    public RespR updateUser(@RequestBody @Validated User user) {
+    public RespR updateUser(@RequestBody @Validated UserVo userVo) {
+        User user = userVo.getUserFromUserVo();
         if (user.getPassword() != null) {
             user.setPassword(Md5Util.encrypt(user.getPassword()));
         }
@@ -105,26 +109,28 @@ public class UserController {
      * 分页查询用户
      *
      * @param page 参数集
-     * @param user 查询参数列表
+     * @param userVo 查询参数列表
      * @return 用户集合
      */
     @PostMapping("/page")
     @ApiOperation(value = "分页查询用户", notes = "分页查询用户")
     @LoginRequired(role = AuthenticationInterceptor.AUTH_ADMIN)
-    public RespR getUserPage(Page page, User user) {
+    public RespR getUserPage(Page page, UserVo userVo) {
+        User user = userVo.getUserFromUserVo();
         return new RespR<>(userService.getUserWithRolePage(page, user));
     }
 
     /**
      * 重置密码
      *
-     * @param user user
+     * @param userVo user
      * @return success/false
      */
     @PutMapping("/restPassword")
     @ApiOperation(value = "重置密码", notes = "重置密码")
     @LoginRequired(role = AuthenticationInterceptor.AUTH_ADMIN)
-    public RespR updateUserInfoPassWord(@RequestBody @Validated({Update.class}) User user) {
+    public RespR updateUserInfoPassWord(@RequestBody @Validated({Update.class}) UserVo userVo) {
+        User user = userVo.getUserFromUserVo();
         user.setPassword(Md5Util.encrypt(user.getPassword()));
         return userService.restPassword(user);
     }
@@ -132,13 +138,14 @@ public class UserController {
     /**
      * 修改锁定状态
      *
-     * @param user user
+     * @param userVo user
      * @return success/false
      */
     @PutMapping("/lock")
     @ApiOperation(value = "修改锁定状态", notes = "修改锁定状态")
     @LoginRequired(role = AuthenticationInterceptor.AUTH_ADMIN)
-    public RespR updateLock(@RequestBody @Validated User user) {
+    public RespR updateLock(@RequestBody @Validated UserVo userVo) {
+        User user = userVo.getUserFromUserVo();
         return userService.updateLock(user);
     }
 }

+ 110 - 0
src/main/java/com/jkcredit/invoice/model/vo/UserVo.java

@@ -0,0 +1,110 @@
+package com.jkcredit.invoice.model.vo;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.jkcredit.invoice.model.entity.user.User;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import org.apache.ibatis.annotations.Update;
+import org.springframework.beans.BeanUtils;
+
+import javax.validation.constraints.NotNull;
+import java.io.Serializable;
+
+/**
+ * @description:
+ * @author: hyh
+ * @create: 2019-05-28 17:44
+ * @version: V1.0
+ **/
+@Data
+@ApiModel(value = "用户实体")
+public class UserVo implements Serializable {
+
+    private static final long serialVersionUID = -526324944915280489L;
+
+    @TableId(type = IdType.AUTO)
+    private Integer id;
+
+    /**
+     * 用户名
+     */
+    @ApiModelProperty(value = "用户名")
+    @NotNull(groups = {Update.class},message = "用户名不能为空")
+    private String userName;
+
+    /**
+     * 密码
+     */
+    @ApiModelProperty(value = "密码")
+    @JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
+    @NotNull(groups = {Update.class},message = "用户密码不能为空")
+    private String password;
+
+    /**
+     * 姓名
+     */
+    @ApiModelProperty(value = "姓名")
+    @NotNull(message = "姓名不能为空")
+    private String name;
+
+    /**
+     * 手机号
+     */
+    @ApiModelProperty(value = "手机号")
+    @NotNull(message = "手机号不能为空")
+    private String phone;
+
+    /**
+     * 行云返回的企业编号
+     */
+    @ApiModelProperty(value = "企业编号")
+    private String companyNum;
+    /**
+     * 企业名称
+     */
+    @ApiModelProperty(value = "企业名称")
+    @NotNull(message = "企业名称不能为空")
+    private String company;
+
+    /**
+     * 角色id
+     */
+    @ApiModelProperty(value = "角色id")
+    @NotNull(message = "角色id不能为空")
+    private String roleId;
+
+    /**
+     * 角色名称
+     */
+    @ApiModelProperty(value = "角色名称")
+    private String roleName;
+
+
+    /**
+     * 创建时间
+     */
+    @ApiModelProperty(value = "创建时间")
+    private Long createTime;
+
+    /**
+     * 锁定状态 0正常 1锁定,2停用
+     */
+    @ApiModelProperty(value = "锁定状态")
+    @NotNull(message = "锁定状态不能为空")
+    private Integer isLock;
+
+    /**
+     * etc卡每月收费,这个不入库
+     */
+    @ApiModelProperty(value = "etc收费")
+    private Double fee;
+
+    public User getUserFromUserVo(){
+        User user = new User();
+        BeanUtils.copyProperties(this,user);
+        return user;
+    }
+}

+ 6 - 4
src/main/java/com/jkcredit/invoice/service/user/impl/UserServiceImpl.java

@@ -58,10 +58,12 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
 
     @Override
     public RespR<Boolean> updateUserInfo(User user) {
-        //更新客户企业主体
-        Customer customer = customerMapper.selectByCustomerName(user.getUserName());
-        customer.setCompany(user.getCompany());
-        customerMapper.updateByPrimaryKeySelective(customer);
+        if (!ONE.equals(user.getRoleId())) {
+            //更新客户企业主体
+            Customer customer = customerMapper.selectByCustomerName(user.getUserName());
+            customer.setCompany(user.getCompany());
+            customerMapper.updateByPrimaryKeySelective(customer);
+        }
         return new RespR<>(baseMapper.updateUserInfo(user));
     }
 

+ 2 - 2
src/main/resources/mapper/user/UserMapper.xml

@@ -61,14 +61,14 @@
         <include refid="userSql"/>
         FROM
             t_user
-       <!-- <where>
+       <where>
             <if test="query.userName != null and query.userName != ''">
                 and  user_name = BINARY #{query.userName}
             </if>
             <if test="query.company != null and query.company != ''">
                 and  company  LIKE BINARY CONCAT('%',#{query.company},'%')
             </if>
-        </where>-->
+        </where>
         order by create_time desc
     </select>