Commit 0a784ddc authored by tangfang's avatar tangfang

用户,角色,权限

parent 37fec4be
......@@ -17,7 +17,7 @@ import org.springframework.scheduling.annotation.EnableScheduling;
* @author Administrator
*/
@SpringBootApplication(scanBasePackages = {
"com..*",
"com.tcm.*",
"com.yanzuoguang.*",
"org.springframework.jdbc.*"
})
......
......@@ -22,13 +22,13 @@ public class TcmAuthorityDaoImpl extends BaseDaoImpl implements TcmAuthorityDao
register(TcmAuthorityVo.class);
table.add(QUERY,"select * from pd_authority where 1=1")
.add("id","and pid = ? ")
table.add(QUERY,"select * from tcm_sys_authority where 1=1")
.add("authorityId","and authority_id = ? ")
.add("pid","and pid = ? ")
.add("sort","and sort = ? ")
.add("search", "and (name like concat(?,'%') " +
"or alias like concat(?,'%')) " )
.add("levelOne","and pid = '' order by sort asc");
.add("authoritySort","and authority_sort = ? ")
.add("search", "and (authority_name like concat(?,'%') " +
"or authority_alias like concat(?,'%')) " )
.add("levelOne","and pid = '' order by authority_sort asc");
}
......
......@@ -16,15 +16,15 @@ public class TcmRoleAuthorityDaoImpl extends BaseDaoImpl implements TcmRoleAutho
protected void init() {
register(TcmRoleAuthorityVo.class);
getSql(DaoConst.LOAD).setSql("select ra.role_id,ra.authority_id,a.id,a.pid,a.name," +
"a.type,a.alias,a.url,a.remark,a.open_mode,a.sort,a.attribute from pd_role_authority ra " +
"RIGHT JOIN pd_authority a on ra.authority_id = a.id {INNER} " +
"where 1=1 {WHERE} ORDER BY a.pid,a.sort,a.attribute" )
.add("userId", "AND b.user_id = @userId",
"{INNER}", "INNER JOIN pd_user_role AS b ON ra.role_id = b.role_id")
.add("role", " AND ra.role_id = @role")
.add("authority", " AND ra.authority_id = @authority")
.add("platformType", " AND a.platform_type = @platformType")
getSql(DaoConst.LOAD).setSql("select a.role_id,b.* " +
" from tcm_sys_role_authority a " +
" RIGHT JOIN tcm_sys_authority b on a.authority_id = b.authority_id {INNER} " +
" where 1=1 {WHERE} ORDER BY b.pid,b.authority_sort,b.attribute" )
.add("userId", "AND c.user_id = @userId",
"{INNER}", "INNER JOIN tcm_sys_user AS c ON a.role_id = c.role_id")
.add("roleId", " AND a.role_id = @roleId")
.add("authorityId", " AND b.authority_id = @authorityId")
.add("platformType", " AND b.platform_type = @platformType")
;
}
......
......@@ -17,10 +17,10 @@ public class TcmRoleDaoImpl extends BaseDaoImpl implements TcmRoleDao {
protected void init() {
register(TcmRoleVo.class);
table.add(QUERY_LIST, "select COUNT(a.id) as userNum,a.* from pd_role a " +
" LEFT JOIN pd_user_role b on a.id = b.role_id where 1=1 {WHERE}" +
"GROUP BY a.id")
.add("id", " and a.id = ? ")
table.add(QUERY_LIST, "select COUNT(a.id) as userNum,a.* from tcm_sys_role a " +
" LEFT JOIN tcm_sys_user b on a.role_id = b.role_id where 1=1 {WHERE}" +
"GROUP BY a.role_id")
.add("roleId", " and a.role_id = ? ")
.add("companyId", " and a.company_id = ? ")
.add("roleName", " and (a.name LIKE concat(?,'%') OR a.remark LIKE concat(?,'%') )");
}
......
package com.tcm.system.role.service;
import com.tcm.system.role.vo.req.TcmRolePageReqVo;
import com.tcm.system.role.vo.req.TcmRoleSaveReqVo;
import com.tcm.system.role.vo.res.TcmRoleListResVo;
import com.yanzuoguang.util.vo.PageSizeData;
......@@ -8,4 +9,8 @@ public interface TcmRoleService {
PageSizeData<TcmRoleListResVo> queryList(TcmRolePageReqVo req);
String saveRole(TcmRoleSaveReqVo req);
void delete(TcmRoleSaveReqVo req);
}
package com.tcm.system.role.service.impl;
import com.pangding.web.constant.CompanyConstant;
import com.pangding.web.vo.system.pd.authority.AuthorityVo;
import com.pangding.web.vo.system.pd.authority.RoleAuthorityVo;
import com.pangding.web.vo.system.pd.authority.RoleVo;
import com.tcm.system.authority.dao.TcmRoleAuthorityDao;
import com.tcm.system.authority.vo.TcmRoleAuthorityVo;
import com.tcm.system.authority.vo.req.TcmRoleAuthorityReqVo;
import com.tcm.system.role.dao.TcmRoleDao;
import com.tcm.system.role.service.TcmRoleService;
import com.tcm.system.role.vo.TcmRoleVo;
import com.tcm.system.role.vo.req.TcmRolePageReqVo;
import com.tcm.system.role.vo.req.TcmRoleSaveReqVo;
import com.tcm.system.role.vo.res.TcmRoleListResVo;
import com.yanzuoguang.util.base.ObjectHelper;
import com.yanzuoguang.util.helper.StringHelper;
import com.yanzuoguang.util.vo.PageSizeData;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
@Service
public class TcmRoleServiceImpl implements TcmRoleService {
private TcmRoleDao tcmRoleDao;
private TcmRoleAuthorityDao tcmRoleAuthorityDao;
public TcmRoleServiceImpl(TcmRoleDao tcmRoleDao) {
public TcmRoleServiceImpl(TcmRoleDao tcmRoleDao, TcmRoleAuthorityDao tcmRoleAuthorityDao) {
this.tcmRoleDao = tcmRoleDao;
this.tcmRoleAuthorityDao = tcmRoleAuthorityDao;
}
public PageSizeData<TcmRoleListResVo> queryList(TcmRolePageReqVo req) {
......@@ -22,5 +38,104 @@ public class TcmRoleServiceImpl implements TcmRoleService {
return roleVoPageSizeData;
}
/**
* 保存RoleVo对象,并保存角色权限的对应关系
*
* @param req
* @return 返回角色id
*/
@Override
@Transactional(rollbackFor = Exception.class)
public String saveRole(TcmRoleSaveReqVo req) {
// this.checkNameExist(roleVo);
if(StringHelper.isEmpty(req.getRoleId())){
req.setRoleId(StringHelper.getNewID());
tcmRoleDao.create(req);
List<String> authorityIds = req.getAuthorityIds();
if (authorityIds != null && !authorityIds.isEmpty()) {
for (String authorityId : authorityIds) {
/*查看该权限是否有上级权限*/
// findParent(authorityId, webRoleReqVo.getId());
TcmRoleAuthorityVo tcmRoleAuthorityVo = new TcmRoleAuthorityVo();
tcmRoleAuthorityVo.setAuthorityId(authorityId);
tcmRoleAuthorityVo.setRoleId(req.getRoleId());
tcmRoleAuthorityVo.setRoleAuthorityId(StringHelper.getNewID());
tcmRoleAuthorityDao.create(tcmRoleAuthorityVo);
}
}
}else{
TcmRoleVo tcmRoleVo = tcmRoleDao.load(req.getRoleId(), TcmRoleVo.class);
ObjectHelper.writeWithFromClass(tcmRoleVo, req);
tcmRoleDao.update(tcmRoleVo);
TcmRoleAuthorityReqVo reqVo = new TcmRoleAuthorityReqVo();
reqVo.setRoleId(tcmRoleVo.getRoleId());
List<TcmRoleAuthorityVo> roleAuthorityList = tcmRoleAuthorityDao.loadList(reqVo, TcmRoleAuthorityVo.class);
if (roleAuthorityList != null && !roleAuthorityList.isEmpty()) {
for (TcmRoleAuthorityVo roleAuthorityRelation : roleAuthorityList) {
RoleAuthorityVo roleAuthorityVo = new RoleAuthorityVo();
roleAuthorityVo.setRoleId(roleAuthorityRelation.getRoleId());
roleAuthorityVo.setAuthorityId(roleAuthorityRelation.getAuthorityId());
tcmRoleAuthorityDao.remove(roleAuthorityVo);
}
}
List<String> authorityIds = req.getAuthorityIds();
if (authorityIds != null && !authorityIds.isEmpty()) {
for (String authorityId : authorityIds) {
/*查看该权限是否有上级权限*/
// findParent(authorityId, webRoleReqVo.getId());
TcmRoleAuthorityVo tcmRoleAuthorityVo = new TcmRoleAuthorityVo();
tcmRoleAuthorityVo.setAuthorityId(authorityId);
tcmRoleAuthorityVo.setRoleId(req.getRoleId());
tcmRoleAuthorityVo.setRoleAuthorityId(StringHelper.getNewID());
tcmRoleAuthorityDao.create(tcmRoleAuthorityVo);
}
}
}
return "处理成功";
}
@Override
@Transactional(rollbackFor = Exception.class)
public void delete(TcmRoleSaveReqVo req) {
TcmRoleAuthorityReqVo reqVo = new TcmRoleAuthorityReqVo();
reqVo.setRoleId(req.getRoleId());
List<TcmRoleAuthorityVo> roleAuthorityList = tcmRoleAuthorityDao.loadList(reqVo, TcmRoleAuthorityVo.class);
if (roleAuthorityList != null && !roleAuthorityList.isEmpty()) {
for (TcmRoleAuthorityVo roleAuthorityRelation : roleAuthorityList) {
RoleAuthorityVo roleAuthorityVo = new RoleAuthorityVo();
roleAuthorityVo.setRoleId(roleAuthorityRelation.getRoleId());
roleAuthorityVo.setAuthorityId(roleAuthorityRelation.getAuthorityId());
tcmRoleAuthorityDao.remove(roleAuthorityVo);
}
}
tcmRoleDao.remove(req);
}
// private void findParent(String authorityId, String roleId) {
// AuthorityGetReqVo authorityGetReqVo = new AuthorityGetReqVo();
// authorityGetReqVo.setId(authorityId);
// AuthorityVo authorityVo = authorityDaoImpl.load(authorityGetReqVo, AuthorityVo.class);
// if (null != authorityVo.getPid() && !authorityVo.getPid().isEmpty()) {
// String authorityPid = authorityVo.getPid();
// RoleAuthorityVo roleAuthorityVo = new RoleAuthorityVo();
// roleAuthorityVo.setAuthorityId(authorityPid);
// roleAuthorityVo.setRoleId(roleId);
// RoleAuthorityGetReqVo roleAuthorityGetReqVo = new RoleAuthorityGetReqVo();
// roleAuthorityGetReqVo.setRole(roleId);
// roleAuthorityGetReqVo.setAuthority(authorityPid);
// RoleAuthorityVo roleAuthorityVo1 = roleAuthorityDaoImpl.load(roleAuthorityGetReqVo, RoleAuthorityVo.class);
// if (null == roleAuthorityVo1) {
// roleAuthorityVo.setId(StringHelper.getNewID());
// roleAuthorityDaoImpl.create(roleAuthorityVo);
// findParent(authorityPid, roleId);
// }
// }
// }
}
package com.tcm.system.role.vo.req;
import com.tcm.system.role.vo.TcmRoleVo;
import java.util.List;
public class TcmRoleSaveReqVo extends TcmRoleVo {
private String reqId;
private List<String> authorityIds;
public String getReqId() {
return reqId;
}
public void setReqId(String reqId) {
this.reqId = reqId;
}
public List<String> getAuthorityIds() {
return authorityIds;
}
public void setAuthorityIds(List<String> authorityIds) {
this.authorityIds = authorityIds;
}
}
......@@ -2,7 +2,9 @@ package com.tcm.system.role.web;
import com.tcm.system.role.service.TcmRoleService;
import com.tcm.system.role.vo.req.TcmRolePageReqVo;
import com.tcm.system.role.vo.req.TcmRoleSaveReqVo;
import com.tcm.system.role.vo.res.TcmRoleListResVo;
import com.yanzuoguang.util.helper.CheckerHelper;
import com.yanzuoguang.util.vo.PageSizeData;
import com.yanzuoguang.util.vo.ResponseResult;
import org.springframework.http.MediaType;
......@@ -29,4 +31,34 @@ public class TcmRoleController {
return ResponseResult.result(tcmRoleService.queryList(req));
}
/**
* 新增角色
* 返回角色id
* @param req
* @return
*/
@RequestMapping(value = "/save", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public ResponseResult<String> saveRole(@RequestBody TcmRoleSaveReqVo req){
CheckerHelper.newInstance()
.notBlankCheck("roleName",req.getRoleName())
.notBlankCheck("remark",req.getRoleRemark())
// .notBlankCheck("companyId",req.getCompanyId())
.checkException();
return ResponseResult.result(tcmRoleService.saveRole(req));
}
/**
* 删除角色
* @param
* @return
*/
@RequestMapping(value = "/delete", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public ResponseResult delete(@RequestBody TcmRoleSaveReqVo req){
CheckerHelper.newInstance()
.notBlankCheck("roleId",req.getRoleId())
.checkException();
tcmRoleService.delete(req);
return new ResponseResult();
}
}
package com.tcm.system.user.dao;
import com.tcm.system.user.vo.req.TcmUserPageReqVo;
import com.tcm.system.user.vo.req.TcmUserReqVo;
import com.tcm.system.user.vo.res.TcmUserResVo;
import com.yanzuoguang.dao.BaseDao;
import com.yanzuoguang.util.vo.PageSizeData;
import java.util.List;
public interface UserDao extends BaseDao {
......@@ -14,4 +18,11 @@ public interface UserDao extends BaseDao {
*/
TcmUserResVo queryUser(TcmUserReqVo req);
PageSizeData<TcmUserResVo> findUserPage(TcmUserPageReqVo req);
List<TcmUserResVo> findUserList(TcmUserReqVo req);
TcmUserResVo findUserInfo(TcmUserReqVo req);
}
......@@ -2,31 +2,62 @@ package com.tcm.system.user.dao.impl;
import com.tcm.system.user.dao.UserDao;
import com.tcm.system.user.vo.TcmUserVo;
import com.tcm.system.user.vo.req.TcmUserPageReqVo;
import com.tcm.system.user.vo.req.TcmUserReqVo;
import com.tcm.system.user.vo.res.TcmUserResVo;
import com.yanzuoguang.dao.impl.BaseDaoImpl;
import com.yanzuoguang.util.vo.PageSizeData;
import org.springframework.stereotype.Component;
import java.util.List;
@Component
public class UserDaoImpl extends BaseDaoImpl implements UserDao {
private static final String QUERY_USER = "QUERY_USER";
private static final String QUERY_LIST = "QUERY_LIST";
@Override
protected void init() {
register(TcmUserVo.class);
table.add(QUERY_USER,"select * from pd_user where 1=1")
table.add(QUERY_USER,"select * from tcm_sys_user where 1=1")
.add("companyId","and company_id = ? ")
.add("account","and account = ? ")
.add("account","and username = ? ")
.add("phone","and phone = ? ")
.add("loginAccount","and (account = ? or phone = ?) ")
.add("roleId"," id in (select user_id from pd_user_role where role_id = ? )");
.add("loginAccount","and (username = ? or phone = ?) ")
.add("roleId"," role_id = ? ");
table.add(QUERY_LIST,"select a.*,b.*,c.* from tcm_sys_user a " +
" LEFT JOIN tcm_sys_role b on a.role_id = b.role_id " +
" LEFT JOIN tcm_sys_position c on c.position_id = a.position_id " +
" where 1=1 ")
.add("companyId","and company_id = ? ")
.add("account","and username = ? ")
.add("phone","and phone = ? ")
.add("loginAccount","and (username = ? or phone = ?) ")
.add("roleId"," role_id = ? ");
}
@Override
public TcmUserResVo queryUser(TcmUserReqVo req) {
return this.queryFirst(TcmUserResVo.class, QUERY_USER, req);
}
@Override
public PageSizeData<TcmUserResVo> findUserPage(TcmUserPageReqVo req) {
return this.queryPage(TcmUserResVo.class, req, QUERY_LIST, req);
}
@Override
public List<TcmUserResVo> findUserList(TcmUserReqVo req) {
return this.query(TcmUserResVo.class, QUERY_LIST, req);
}
@Override
public TcmUserResVo findUserInfo(TcmUserReqVo req) {
return this.queryFirst(TcmUserResVo.class, QUERY_LIST, req);
}
}
package com.tcm.system.user.service;
import com.google.code.kaptcha.impl.DefaultKaptcha;
import com.google.code.kaptcha.util.Config;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;
import java.util.Properties;
/**
* 验证码生成配置
*
* @author 颜佐光
*/
@Component
public class KaptchConfig {
@Bean
public DefaultKaptcha getDefaultKaptcha() {
DefaultKaptcha defaultKaptcha = new DefaultKaptcha();
Properties properties = new Properties();
// 图片边框
properties.setProperty("kaptcha.border", "no");
// 边框颜色
properties.setProperty("kaptcha.border.color", "black");
//边框厚度
properties.setProperty("kaptcha.border.thickness", "1");
// 图片宽
properties.setProperty("kaptcha.image.width", "120");
// 图片高
properties.setProperty("kaptcha.image.height", "60");
//图片实现类
properties.setProperty("kaptcha.producer.impl", "com.google.code.kaptcha.impl.DefaultKaptcha");
//文本实现类
properties.setProperty("kaptcha.textproducer.impl", "com.google.code.kaptcha.text.impl.DefaultTextCreator");
//文本集合,验证码值从此集合中获取
// properties.setProperty("kaptcha.textproducer.char.string", "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ");
properties.setProperty("kaptcha.textproducer.char.string", "23456789ABCDEFGHJKMNPQRSTUVWXYZ");
//验证码长度
properties.setProperty("kaptcha.textproducer.char.length", "4");
//字体
properties.setProperty("kaptcha.textproducer.font.names", "宋体");
//字体颜色
properties.setProperty("kaptcha.textproducer.font.color", "black");
//文字间隔
properties.setProperty("kaptcha.textproducer.char.space", "2");
//干扰实现类
properties.setProperty("kaptcha.noise.impl", "com.google.code.kaptcha.impl.DefaultNoise");
//干扰颜色
properties.setProperty("kaptcha.noise.color", "blue");
//干扰图片样式
properties.setProperty("kaptcha.obscurificator.impl", "com.google.code.kaptcha.impl.WaterRipple");
//背景实现类
properties.setProperty("kaptcha.background.impl", "com.google.code.kaptcha.impl.DefaultBackground");
// 验证码背景颜色(开始颜色)
properties.setProperty("kaptcha.background-color.from", "lightGray");
// 验证码背景颜色(结束颜色)
properties.setProperty("kaptcha.background-color.to", "white");
//背景颜色渐变,结束颜色
properties.setProperty("kaptcha.background.clear.to", "white");
//文字渲染器
properties.setProperty("kaptcha.word.impl", "com.google.code.kaptcha.text.impl.DefaultWordRenderer");
Config config = new Config(properties);
defaultKaptcha.setConfig(config);
return defaultKaptcha;
}
}
package com.tcm.system.user.service;
import com.tcm.system.user.vo.req.TcmUserPageReqVo;
import com.tcm.system.user.vo.req.TcmUserReqVo;
import com.tcm.system.user.vo.req.TcmUserSaveReqVo;
import com.tcm.system.user.vo.res.TcmUserResVo;
import com.yanzuoguang.util.vo.PageSizeData;
import java.util.List;
public interface UserService {
......@@ -13,6 +17,12 @@ public interface UserService {
*/
TcmUserResVo queryUser(TcmUserReqVo req);
PageSizeData<TcmUserResVo> findUserPage(TcmUserPageReqVo req);
List<TcmUserResVo> findUserList(TcmUserReqVo req);
TcmUserResVo findUserInfo(TcmUserReqVo req);
String saveUser(TcmUserSaveReqVo req);
}
......@@ -21,7 +21,7 @@ import java.util.concurrent.TimeUnit;
@Component
public class ValidateCodeService {
private final DefaultKaptcha defaultKaptcha;
private DefaultKaptcha defaultKaptcha;
@CreateCache(name = CacheName.USER_PASSWORD_CODE, cacheType = CacheType.REMOTE, expire = 60, timeUnit = TimeUnit.MINUTES)
......@@ -31,7 +31,6 @@ public class ValidateCodeService {
this.defaultKaptcha = defaultKaptcha;
}
/**
* 生成验证码
*
......
......@@ -54,10 +54,10 @@ public class LoginServiceImpl implements LoginService {
@Override
public UserLoginResVo login(UserLoginReqVo reqVo){
// 当输入用户名和密码时,检测验证码
List<String> items = new ArrayList<>();
items.add(reqVo.getAccountOrPhone());
items.add(reqVo.getPassword());
validateCodeService.validate(reqVo.getCodeId(), reqVo.getCodeValue(), items);
// List<String> items = new ArrayList<>();
// items.add(reqVo.getAccountOrPhone());
// items.add(reqVo.getPassword());
// validateCodeService.validate(reqVo.getCodeId(), reqVo.getCodeValue(), items);
TcmUserReqVo userReqVo = new TcmUserReqVo();
userReqVo.setLoginAccount(reqVo.getAccountOrPhone());
......@@ -97,7 +97,7 @@ public class LoginServiceImpl implements LoginService {
/*获取用户权限列表*/
TcmRoleAuthorityReqVo roleAuthorityGetReqVo = new TcmRoleAuthorityReqVo();
roleAuthorityGetReqVo.setUserId(userVo.getUserId());
List<TcmAuthorityListByLevelResVo> roleAuthorityVoList = tcmAuthorityService.findAuthorityListByLevel(roleAuthorityGetReqVo);
List<TcmAuthorityListByLevelResVo> roleAuthorityVoList = tcmAuthorityService.getListByLevel(roleAuthorityGetReqVo);
resVo.setAuthorityListByLevel(roleAuthorityVoList);
resVo.setCode("00");
......
......@@ -6,14 +6,18 @@ import com.tcm.system.user.dao.UserDao;
import com.tcm.system.user.service.UserService;
import com.tcm.system.user.vo.RsaContant;
import com.tcm.system.user.vo.TcmUserVo;
import com.tcm.system.user.vo.req.TcmUserPageReqVo;
import com.tcm.system.user.vo.req.TcmUserReqVo;
import com.tcm.system.user.vo.req.TcmUserSaveReqVo;
import com.tcm.system.user.vo.res.TcmUserResVo;
import com.yanzuoguang.util.base.ObjectHelper;
import com.yanzuoguang.util.exception.CodeException;
import com.yanzuoguang.util.helper.StringHelper;
import com.yanzuoguang.util.vo.PageSizeData;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class UserServiceImpl implements UserService {
......@@ -29,6 +33,22 @@ public class UserServiceImpl implements UserService {
public TcmUserResVo queryUser(TcmUserReqVo req) {
return userDao.queryUser(req);
}
@Override
public PageSizeData<TcmUserResVo> findUserPage(TcmUserPageReqVo req){
return userDao.findUserPage(req);
}
@Override
public List<TcmUserResVo> findUserList(TcmUserReqVo req){
return userDao.findUserList(req);
}
@Override
public TcmUserResVo findUserInfo(TcmUserReqVo req){
return userDao.findUserInfo(req);
}
@Override
public String saveUser(TcmUserSaveReqVo req) {
this.isValid(req.getUsername());
......
package com.tcm.system.user;
import com.yanzuoguang.util.helper.SwaggerHelper;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
@Configuration
@EnableSwagger2
public class swagger {
@Bean
public Docket createRestApi() {
return new Docket(DocumentationType.SWAGGER_2)
.apiInfo(apiInfo())
.select()
//为当前包路径
.apis(SwaggerHelper.basePackage(
"com.pangding.web.authority.web",
"com.pangding.web.user.web",
"com.pangding.web.role.web"
))
.paths(PathSelectors.any())
.build();
// return new Docket(DocumentationType.SWAGGER_2).select().apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class)).build();
}
//构建 api文档的详细信息函数,注意这里的注解引用的是哪个
private ApiInfo apiInfo() {
return new ApiInfoBuilder()
//页面标题
.title("Spring Boot 使用 Swagger2 构建RESTful API")
//创建人
.contact(new Contact("Bryan", "http://blog.bianxh.top/", ""))
//版本号
.version("1.0")
//描述
.description("API 描述")
.build();
}
}
package com.tcm.system.user.vo.req;
import com.yanzuoguang.util.vo.PageSizeReqVo;
import io.swagger.annotations.ApiModelProperty;
public class TcmUserPageReqVo extends PageSizeReqVo {
@ApiModelProperty(notes ="用户编号")
private String userId;
private String roleId;
private String positionId;
private String roleName;
private String positionName;
@ApiModelProperty(notes ="账户")
private String username;
@ApiModelProperty(notes ="真实姓名")
private String realName;
@ApiModelProperty(notes ="电话")
private String phone;
@ApiModelProperty(notes ="状态:0-启用,1-禁用")
private Integer userStatus;
public String getUserId() {
return userId;
}
public void setUserId(String userId) {
this.userId = userId;
}
public String getRoleId() {
return roleId;
}
public void setRoleId(String roleId) {
this.roleId = roleId;
}
public String getPositionId() {
return positionId;
}
public void setPositionId(String positionId) {
this.positionId = positionId;
}
public String getRoleName() {
return roleName;
}
public void setRoleName(String roleName) {
this.roleName = roleName;
}
public String getPositionName() {
return positionName;
}
public void setPositionName(String positionName) {
this.positionName = positionName;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getRealName() {
return realName;
}
public void setRealName(String realName) {
this.realName = realName;
}
public String getPhone() {
return phone;
}
public void setPhone(String phone) {
this.phone = phone;
}
public Integer getUserStatus() {
return userStatus;
}
public void setUserStatus(Integer userStatus) {
this.userStatus = userStatus;
}
}
......@@ -3,4 +3,24 @@ package com.tcm.system.user.vo.res;
import com.tcm.system.user.vo.TcmUserVo;
public class TcmUserResVo extends TcmUserVo {
private String roleName;
private String positionName;
public String getRoleName() {
return roleName;
}
public void setRoleName(String roleName) {
this.roleName = roleName;
}
public String getPositionName() {
return positionName;
}
public void setPositionName(String positionName) {
this.positionName = positionName;
}
}
......@@ -38,7 +38,7 @@ public class LoginController {
CheckerHelper.newInstance()
.notBlankCheck("account or phone", req.getAccountOrPhone())
.notBlankCheck("password", req.getPassword())
.notBlankCheck("loginType", req.getLoginType())
// .notBlankCheck("loginType", req.getLoginType())
.checkException();
return ResponseResult.result(loginService.login(req));
}
......
package com.tcm.system.user.web;
import com.tcm.system.user.service.UserService;
import com.tcm.system.user.vo.req.TcmUserPageReqVo;
import com.tcm.system.user.vo.req.TcmUserReqVo;
import com.tcm.system.user.vo.req.TcmUserSaveReqVo;
import com.tcm.system.user.vo.res.TcmUserResVo;
import com.yanzuoguang.util.vo.PageSizeData;
import com.yanzuoguang.util.vo.ResponseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
@RestController
@RequestMapping(value="/user")
@Api(value = "用户类")
public class TcmUserController {
private UserService userService;
public TcmUserController(UserService userService) {
this.userService = userService;
}
/**
* 分页查询员工信息
* @param req
* @return
*/
@ApiOperation(value ="分页查询员工信息", notes = "返回员工信息列表")
@RequestMapping(value = "/findUserPage", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public ResponseResult<PageSizeData<TcmUserResVo>> findUserPage(@RequestBody TcmUserPageReqVo req) {
return ResponseResult.result(userService.findUserPage(req));
}
@ApiOperation(value ="查询员工信息", notes = "返回员工信息列表")
@RequestMapping(value = "/findUserList", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public ResponseResult<List<TcmUserResVo>> findUserList(@RequestBody TcmUserReqVo req) {
return ResponseResult.result(userService.findUserList(req));
}
@ApiOperation(value ="查询员工信息", notes = "返回员工信息")
@RequestMapping(value = "/findUserInfo", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public ResponseResult<TcmUserResVo> findUserInfo(@RequestBody TcmUserReqVo req) {
return ResponseResult.result(userService.findUserInfo(req));
}
@ApiOperation(value ="保存员工信息", notes = "返回成功失败")
@RequestMapping(value = "/saveUser", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public ResponseResult<String> saveUser(@RequestBody TcmUserSaveReqVo req) {
return ResponseResult.result(userService.saveUser(req));
}
}
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