Commit f9fc40fc by giaogiao

商家: 账户管理,添加账号,删除账号,修改账号, 账号列表

parent f96a5897
package com.jumeirah.api.merchant.controller; package com.jumeirah.api.merchant.controller;
import com.jumeirah.common.entity.MerchantUser;
import com.jumeirah.common.param.MerchantLoginParam; import com.jumeirah.common.param.MerchantLoginParam;
import com.jumeirah.common.param.MerchantUserPageParam;
import com.jumeirah.common.service.MerchantService; import com.jumeirah.common.service.MerchantService;
import com.jumeirah.common.service.MerchantUserService; import com.jumeirah.common.service.MerchantUserService;
import com.jumeirah.common.vo.LoginMerUserTokenVo; import com.jumeirah.common.vo.LoginMerUserTokenVo;
import com.jumeirah.common.vo.MerchantUserQueryVo;
import io.geekidea.springbootplus.framework.common.api.ApiResult; import io.geekidea.springbootplus.framework.common.api.ApiResult;
import io.geekidea.springbootplus.framework.common.controller.BaseController; import io.geekidea.springbootplus.framework.common.controller.BaseController;
import io.geekidea.springbootplus.framework.core.pagination.Paging;
import io.geekidea.springbootplus.framework.core.validator.groups.Add;
import io.geekidea.springbootplus.framework.core.validator.groups.Update;
import io.geekidea.springbootplus.framework.log.annotation.Module; import io.geekidea.springbootplus.framework.log.annotation.Module;
import io.geekidea.springbootplus.framework.log.annotation.OperationLog;
import io.geekidea.springbootplus.framework.log.annotation.OperationLogIgnore; import io.geekidea.springbootplus.framework.log.annotation.OperationLogIgnore;
import io.geekidea.springbootplus.framework.log.enums.OperationLogType;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
...@@ -48,60 +38,60 @@ public class MerchantUserController extends BaseController { ...@@ -48,60 +38,60 @@ public class MerchantUserController extends BaseController {
@Autowired @Autowired
private MerchantService merchantService; private MerchantService merchantService;
/** // /**
* 添加商家用户 // * 添加商家用户
*/ // */
@PostMapping("/add") // @PostMapping("/add")
@OperationLog(name = "添加商家用户", type = OperationLogType.ADD) // @OperationLog(name = "添加商家用户", type = OperationLogType.ADD)
@ApiOperation(value = "添加商家用户", response = ApiResult.class) // @ApiOperation(value = "添加商家用户", response = ApiResult.class)
public ApiResult<Boolean> addMerchantUser(@Validated(Add.class) @RequestBody MerchantUser merchantUser) throws Exception { // public ApiResult<Boolean> addMerchantUser(@Validated(Add.class) @RequestBody MerchantUser merchantUser) throws Exception {
boolean flag = merchantUserService.saveMerchantUser(merchantUser); // boolean flag = merchantUserService.saveMerchantUser(merchantUser);
return ApiResult.result(flag); // return ApiResult.result(flag);
} // }
//
/** // /**
* 修改商家用户 // * 修改商家用户
*/ // */
@PostMapping("/update") // @PostMapping("/update")
@OperationLog(name = "修改商家用户", type = OperationLogType.UPDATE) // @OperationLog(name = "修改商家用户", type = OperationLogType.UPDATE)
@ApiOperation(value = "修改商家用户", response = ApiResult.class) // @ApiOperation(value = "修改商家用户", response = ApiResult.class)
public ApiResult<Boolean> updateMerchantUser(@Validated(Update.class) @RequestBody MerchantUser merchantUser) throws Exception { // public ApiResult<Boolean> updateMerchantUser(@Validated(Update.class) @RequestBody MerchantUser merchantUser) throws Exception {
boolean flag = merchantUserService.updateMerchantUser(merchantUser); // boolean flag = merchantUserService.updateMerchantUser(merchantUser);
return ApiResult.result(flag); // return ApiResult.result(flag);
} // }
//
/** // /**
* 删除商家用户 // * 删除商家用户
*/ // */
@PostMapping("/delete/{id}") // @PostMapping("/delete/{id}")
@OperationLog(name = "删除商家用户", type = OperationLogType.DELETE) // @OperationLog(name = "删除商家用户", type = OperationLogType.DELETE)
@ApiOperation(value = "删除商家用户", response = ApiResult.class) // @ApiOperation(value = "删除商家用户", response = ApiResult.class)
public ApiResult<Boolean> deleteMerchantUser(@PathVariable("id") Long id) throws Exception { // public ApiResult<Boolean> deleteMerchantUser(@PathVariable("id") Long id) throws Exception {
boolean flag = merchantUserService.deleteMerchantUser(id); // boolean flag = merchantUserService.deleteMerchantUser(id);
return ApiResult.result(flag); // return ApiResult.result(flag);
} // }
//
/** // /**
* 获取商家用户详情 // * 获取商家用户详情
*/ // */
@GetMapping("/info/{id}") // @GetMapping("/info/{id}")
@OperationLog(name = "商家用户详情", type = OperationLogType.INFO) // @OperationLog(name = "商家用户详情", type = OperationLogType.INFO)
@ApiOperation(value = "商家用户详情", response = MerchantUserQueryVo.class) // @ApiOperation(value = "商家用户详情", response = MerchantUserQueryVo.class)
public ApiResult<MerchantUserQueryVo> getMerchantUser(@PathVariable("id") Long id) throws Exception { // public ApiResult<MerchantUserQueryVo> getMerchantUser(@PathVariable("id") Long id) throws Exception {
MerchantUserQueryVo merchantUserQueryVo = merchantUserService.getMerchantUserById(id); // MerchantUserQueryVo merchantUserQueryVo = merchantUserService.getMerchantUserById(id);
return ApiResult.ok(merchantUserQueryVo); // return ApiResult.ok(merchantUserQueryVo);
} // }
//
/** // /**
* 商家用户分页列表 // * 商家用户分页列表
*/ // */
@PostMapping("/getPageList") // @PostMapping("/getPageList")
@OperationLog(name = "商家用户分页列表", type = OperationLogType.PAGE) // @OperationLog(name = "商家用户分页列表", type = OperationLogType.PAGE)
@ApiOperation(value = "商家用户分页列表", response = MerchantUserQueryVo.class) // @ApiOperation(value = "商家用户分页列表", response = MerchantUserQueryVo.class)
public ApiResult<Paging<MerchantUserQueryVo>> getMerchantUserPageList(@Validated @RequestBody MerchantUserPageParam merchantUserPageParam) throws Exception { // public ApiResult<Paging<MerchantUserQueryVo>> getMerchantUserPageList(@Validated @RequestBody MerchantUserPageParam merchantUserPageParam) throws Exception {
Paging<MerchantUserQueryVo> paging = merchantUserService.getMerchantUserPageList(merchantUserPageParam); // Paging<MerchantUserQueryVo> paging = merchantUserService.getMerchantUserPageList(merchantUserPageParam);
return ApiResult.ok(paging); // return ApiResult.ok(paging);
} // }
@PostMapping("/login") @PostMapping("/login")
@OperationLogIgnore @OperationLogIgnore
......
package com.jumeirah.api.merchant.controller;
import com.jumeirah.api.merchant.entity.param.MerchantUserAddParam;
import com.jumeirah.api.merchant.entity.param.MerchantUserUpdateParam;
import com.jumeirah.common.entity.MerchantUser;
import com.jumeirah.common.service.MerchantService;
import com.jumeirah.common.service.MerchantUserService;
import com.jumeirah.common.vo.MerchantUserQueryVo;
import io.geekidea.springbootplus.framework.common.api.ApiResult;
import io.geekidea.springbootplus.framework.common.controller.BaseController;
import io.geekidea.springbootplus.framework.core.validator.groups.Add;
import io.geekidea.springbootplus.framework.core.validator.groups.Update;
import io.geekidea.springbootplus.framework.log.annotation.Module;
import io.geekidea.springbootplus.framework.log.annotation.OperationLog;
import io.geekidea.springbootplus.framework.log.enums.OperationLogType;
import io.geekidea.springbootplus.framework.shiro.jwt.JwtToken;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.SecurityUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
* 商家用户 控制器
*
* @author wei
* @since 2020-09-27
*/
@Slf4j
@RestController
@RequestMapping("/merchant/user/manager")
@Module("${cfg.module}")
@Api(value = "商家账户管理API", tags = {"商家账户管理"})
public class MerchantUserManagerController extends BaseController {
@Autowired
private MerchantUserService merchantUserService;
@Autowired
private MerchantService merchantService;
/**
* 添加商家用户
*/
@PostMapping("/add")
@OperationLog(name = "添加商家用户", type = OperationLogType.ADD)
@ApiOperation(value = "添加商家用户", response = ApiResult.class)
public ApiResult<Boolean> addMerchantUser(@Validated(Add.class) @RequestBody MerchantUserAddParam merchantUserAddParam) throws Exception {
MerchantUser merchantUser = new MerchantUser();
BeanUtils.copyProperties(merchantUserAddParam, merchantUser);
boolean flag = merchantUserService.saveMerchantUser(merchantUser);
return ApiResult.result(flag);
}
/**
* 修改商家用户
*/
@PostMapping("/update")
@OperationLog(name = "修改商家用户", type = OperationLogType.UPDATE)
@ApiOperation(value = "修改商家用户", response = ApiResult.class)
public ApiResult<Boolean> updateMerchantUser(@Validated(Update.class) @RequestBody MerchantUserUpdateParam merchantUserUpdateParam) throws Exception {
MerchantUser merchantUser = new MerchantUser();
BeanUtils.copyProperties(merchantUserUpdateParam, merchantUser);
boolean flag = merchantUserService.updateMerchantUser(merchantUser);
return ApiResult.result(flag);
}
/**
* 删除商家用户
*/
@PostMapping("/delete/{id}")
@OperationLog(name = "删除商家用户", type = OperationLogType.DELETE)
@ApiOperation(value = "删除商家用户", response = ApiResult.class)
public ApiResult<Boolean> deleteMerchantUser(@PathVariable("id") Long id) throws Exception {
boolean flag = merchantUserService.deleteMerchantUser(id);
return ApiResult.result(flag);
}
/**
* 获取商家用户详情
*/
@GetMapping("/info/{id}")
@OperationLog(name = "商家用户详情", type = OperationLogType.INFO)
@ApiOperation(value = "商家用户详情", response = MerchantUserQueryVo.class)
public ApiResult<MerchantUserQueryVo> getMerchantUser(@PathVariable("id") Long id) throws Exception {
MerchantUserQueryVo merchantUserQueryVo = merchantUserService.getMerchantUserById(id);
return ApiResult.ok(merchantUserQueryVo);
}
/**
* 商家用户分页列表
*/
@PostMapping("/getPageList")
@OperationLog(name = "商家用户分页列表", type = OperationLogType.PAGE)
@ApiOperation(value = "商家用户分页列表")
public ApiResult<List<MerchantUserQueryVo>> getMerchantUserPageList() throws Exception {
JwtToken jwtToken = (JwtToken) SecurityUtils.getSubject().getPrincipal();
List<MerchantUserQueryVo> merchantUserListByMcId = merchantUserService.getMerchantUserListByMcId(jwtToken.getMcId());
return ApiResult.ok(merchantUserListByMcId);
}
}
package com.jumeirah.api.merchant.entity.param;
import io.geekidea.springbootplus.framework.common.entity.BaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import javax.validation.constraints.NotBlank;
/**
* 商家
*
* @author wei
* @since 2020-09-28
*/
@Data
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = true)
@ApiModel(value = "MerchantUserAddParam对象")
public class MerchantUserAddParam extends BaseEntity {
private static final long serialVersionUID = 1L;
@NotBlank(message = "账号不能为空")
@ApiModelProperty("账号")
private String username;
@NotBlank(message = "密码不能为空")
@ApiModelProperty("密码")
private String password;
@ApiModelProperty("职位")
private String remark;
}
package com.jumeirah.api.merchant.entity.param;
import io.geekidea.springbootplus.framework.common.entity.BaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import javax.validation.constraints.NotBlank;
/**
* 商家
*
* @author wei
* @since 2020-09-28
*/
@Data
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = true)
@ApiModel(value = "MerchantUserUpdateParam对象")
public class MerchantUserUpdateParam extends BaseEntity {
private static final long serialVersionUID = 1L;
@ApiModelProperty("用户名")
private String username;
@ApiModelProperty("昵称")
private String nickname;
@NotBlank(message = "密码不能为空")
@ApiModelProperty("密码")
private String password;
@ApiModelProperty("备注")
private String remark;
}
...@@ -10,6 +10,7 @@ import org.apache.ibatis.annotations.Param; ...@@ -10,6 +10,7 @@ import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
import java.io.Serializable; import java.io.Serializable;
import java.util.List;
/** /**
* 商家 Mapper 接口 * 商家 Mapper 接口
...@@ -37,4 +38,6 @@ public interface MerchantUserMapper extends BaseMapper<MerchantUser> { ...@@ -37,4 +38,6 @@ public interface MerchantUserMapper extends BaseMapper<MerchantUser> {
*/ */
IPage<MerchantUserQueryVo> getMerchantUserPageList(@Param("page") Page page, @Param("param") MerchantUserPageParam merchantUserPageParam); IPage<MerchantUserQueryVo> getMerchantUserPageList(@Param("page") Page page, @Param("param") MerchantUserPageParam merchantUserPageParam);
List<MerchantUserQueryVo> getMerchantUserListByMcId(Serializable id);
} }
...@@ -9,6 +9,8 @@ import io.geekidea.springbootplus.framework.common.api.ApiResult; ...@@ -9,6 +9,8 @@ import io.geekidea.springbootplus.framework.common.api.ApiResult;
import io.geekidea.springbootplus.framework.common.service.BaseService; import io.geekidea.springbootplus.framework.common.service.BaseService;
import io.geekidea.springbootplus.framework.core.pagination.Paging; import io.geekidea.springbootplus.framework.core.pagination.Paging;
import java.util.List;
/** /**
* 商家 服务类 * 商家 服务类
* *
...@@ -75,6 +77,7 @@ public interface MerchantUserService extends BaseService<MerchantUser> { ...@@ -75,6 +77,7 @@ public interface MerchantUserService extends BaseService<MerchantUser> {
*/ */
Paging<MerchantUserQueryVo> getMerchantUserPageList(MerchantUserPageParam merchantUserPageParam) throws Exception; Paging<MerchantUserQueryVo> getMerchantUserPageList(MerchantUserPageParam merchantUserPageParam) throws Exception;
List<MerchantUserQueryVo> getMerchantUserListByMcId(Long mcId) throws Exception;
......
...@@ -250,8 +250,13 @@ public class MerchantUserServiceImpl extends BaseServiceImpl<MerchantUserMapper, ...@@ -250,8 +250,13 @@ public class MerchantUserServiceImpl extends BaseServiceImpl<MerchantUserMapper,
public Paging<MerchantUserQueryVo> getMerchantUserPageList(MerchantUserPageParam merchantUserPageParam) throws Exception { public Paging<MerchantUserQueryVo> getMerchantUserPageList(MerchantUserPageParam merchantUserPageParam) throws Exception {
Page<MerchantUserQueryVo> page = new PageInfo<>(merchantUserPageParam, OrderItem.desc(getLambdaColumn(MerchantUser::getCreateTime))); Page<MerchantUserQueryVo> page = new PageInfo<>(merchantUserPageParam, OrderItem.desc(getLambdaColumn(MerchantUser::getCreateTime)));
IPage<MerchantUserQueryVo> iPage = merchantUserMapper.getMerchantUserPageList(page, merchantUserPageParam); IPage<MerchantUserQueryVo> iPage = merchantUserMapper.getMerchantUserPageList(page, merchantUserPageParam);
return new Paging<MerchantUserQueryVo>(iPage); return new Paging<>(iPage);
} }
@Override
public List<MerchantUserQueryVo> getMerchantUserListByMcId(Long mcId) throws Exception {
return merchantUserMapper.getMerchantUserListByMcId(mcId);
}
} }
...@@ -20,7 +20,13 @@ ...@@ -20,7 +20,13 @@
from merchant_user from merchant_user
</select> </select>
<select id="getMerchantUserListByMcId" parameterType="com.jumeirah.common.param.MerchantUserPageParam"
resultType="com.jumeirah.common.vo.MerchantUserQueryVo">
select
id,mc_id,is_admin, username, nickname, phone, phone_area, gender, head, remark, state, role_id, deleted, version, create_time, update_time
from merchant_user
where where mc_id = #{id}
</select>
</mapper> </mapper>
...@@ -43,7 +43,7 @@ public class JwtToken implements HostAuthenticationToken { ...@@ -43,7 +43,7 @@ public class JwtToken implements HostAuthenticationToken {
private String type; private String type;
/** /**
* mcId * 商家mcId
*/ */
private Long mcId; private Long mcId;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment