d8384bbe 张雷

修改厂站人员接口

1 个父辈 131938af
......@@ -11,6 +11,8 @@ import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.skua.modules.system.entity.SysUser;
import com.skua.modules.system.service.ISysUserService;
import org.apache.commons.lang.StringUtils;
import org.jeecgframework.poi.excel.ExcelImportUtil;
import org.jeecgframework.poi.excel.def.NormalExcelConstants;
......@@ -63,6 +65,8 @@ public class SysFactoryUserInfoController {
@Autowired
private ISysFactoryUserInfoService sysFactoryUserInfoService;
@Autowired
private ISysUserService sysUserService;
@Autowired
private ISequenceService sequenceService;
/**
* 分页列表查询
......@@ -80,15 +84,16 @@ public class SysFactoryUserInfoController {
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
HttpServletRequest req) {
Result<IPage<SysFactoryUserInfo>> result = new Result<IPage<SysFactoryUserInfo>>();
QueryWrapper<SysFactoryUserInfo> queryWrapper = QueryGenerator.initQueryWrapper(sysFactoryUserInfo, req.getParameterMap());
String departIds = BaseContextHandler.getDeparts();
String[] departIdArray = departIds.split(",");
if(StringUtils.isEmpty(sysFactoryUserInfo.getDepartId())&&StringUtils.isNotBlank(departIds)) {
queryWrapper.in("depart_id", departIdArray);
}
queryWrapper.eq(StringUtils.isNotEmpty(sysFactoryUserInfo.getDepartId()),"depart_id",sysFactoryUserInfo.getDepartId());
Page<SysFactoryUserInfo> page = new Page<SysFactoryUserInfo>(pageNo, pageSize);
IPage<SysFactoryUserInfo> pageList = sysFactoryUserInfoService.page(page, queryWrapper);
// QueryWrapper<SysFactoryUserInfo> queryWrapper = QueryGenerator.initQueryWrapper(sysFactoryUserInfo, req.getParameterMap());
// String departIds = BaseContextHandler.getDeparts();
// String[] departIdArray = departIds.split(",");
// if(StringUtils.isEmpty(sysFactoryUserInfo.getDepartId())&&StringUtils.isNotBlank(departIds)) {
// queryWrapper.in("depart_id", departIdArray);
// }
// queryWrapper.eq(StringUtils.isNotEmpty(sysFactoryUserInfo.getDepartId()),"depart_id",sysFactoryUserInfo.getDepartId());
// IPage<SysFactoryUserInfo> pageList = sysFactoryUserInfoService.page(page, queryWrapper);
IPage<SysFactoryUserInfo> pageList = sysFactoryUserInfoService.getPage(page, sysFactoryUserInfo);
result.setSuccess(true);
result.setResult(pageList);
return result;
......@@ -101,14 +106,14 @@ public class SysFactoryUserInfoController {
Result<Map<String,Object>> result = new Result<Map<String,Object>>();
Map<String,Object> map = new HashMap<>();
int female = 0;int male = 0;
QueryWrapper<SysFactoryUserInfo> queryWrapper = new QueryWrapper<>();
String departIds = BaseContextHandler.getDeparts();
String[] departIdArray = departIds.split(",");
if(StringUtils.isEmpty(sysFactoryUserInfo.getDepartId())&&StringUtils.isNotBlank(departIds)) {
queryWrapper.in("depart_id", departIdArray);
}
queryWrapper.eq(StringUtils.isNotEmpty(sysFactoryUserInfo.getDepartId()),"depart_id",sysFactoryUserInfo.getDepartId());
List<SysFactoryUserInfo> list = sysFactoryUserInfoService.list(queryWrapper);
// QueryWrapper<SysFactoryUserInfo> queryWrapper = new QueryWrapper<>();
// String departIds = BaseContextHandler.getDeparts();
// String[] departIdArray = departIds.split(",");
// if(StringUtils.isEmpty(sysFactoryUserInfo.getDepartId())&&StringUtils.isNotBlank(departIds)) {
// queryWrapper.in("depart_id", departIdArray);
// }
// queryWrapper.eq(StringUtils.isNotEmpty(sysFactoryUserInfo.getDepartId()),"depart_id",sysFactoryUserInfo.getDepartId());
List<SysFactoryUserInfo> list = sysFactoryUserInfoService.getList(sysFactoryUserInfo);
if(list.size()>0){
map.put("total", list.size());
for (SysFactoryUserInfo factoryUserInfo : list) {
......@@ -141,6 +146,15 @@ public class SysFactoryUserInfoController {
public Result<SysFactoryUserInfo> add(@RequestBody SysFactoryUserInfo sysFactoryUserInfo) {
Result<SysFactoryUserInfo> result = new Result<SysFactoryUserInfo>();
try {
if(StringUtils.isNotEmpty(sysFactoryUserInfo.getUserId())){
SysUser user = sysUserService.getById(sysFactoryUserInfo.getUserId());
if(ConvertUtils.isNotEmpty(user)){
sysFactoryUserInfo.setUserName(user.getRealname());
sysFactoryUserInfo.setEmail(user.getEmail());
sysFactoryUserInfo.setTelephone(user.getPhone());
sysFactoryUserInfo.setSex(user.getSalt());
}
}
sysFactoryUserInfo.setId(String.valueOf(sequenceService.nextId()));
sysFactoryUserInfoService.save(sysFactoryUserInfo);
result.success("添加成功!");
......@@ -166,7 +180,6 @@ public class SysFactoryUserInfoController {
result.error500("未找到对应实体");
}else {
boolean ok = sysFactoryUserInfoService.updateById(sysFactoryUserInfo);
//TODO 返回false说明什么?
if(ok) {
result.success("修改成功!");
}
......
package com.skua.modules.system.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.skua.core.aspect.annotation.Dict;
......@@ -43,6 +44,9 @@ public class SysFactoryUserInfo {
/**邮箱*/
@ApiModelProperty(value = "邮箱")
private java.lang.String email;
/**工号*/
@ApiModelProperty(value = "工号")
private java.lang.String workNo;
/**学历*/
@ApiModelProperty(value = "学历")
private java.lang.String degree;
......@@ -74,4 +78,7 @@ public class SysFactoryUserInfo {
/**合同到期时间*/
@ApiModelProperty(value = "合同到期时间")
private java.lang.String contractEnddate;
/**角色*/
@TableField(exist = false)
private String roleName;
}
......
......@@ -11,4 +11,6 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
*/
public interface SysFactoryUserInfoMapper extends BaseMapper<SysFactoryUserInfo> {
List<SysFactoryUserInfo> getList(String departIds, String userName);
}
......
......@@ -2,4 +2,25 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.skua.modules.system.mapper.SysFactoryUserInfoMapper">
</mapper>
\ No newline at end of file
<select id="getList" resultType="com.skua.modules.system.entity.SysFactoryUserInfo">
SELECT
group_concat( DISTINCT ( SELECT r.role_name FROM sys_role r WHERE r.id = sur.role_id ) ) role_name,
fu.*
FROM
sys_factory_user_info fu
LEFT JOIN sys_user_role sur ON fu.user_id = sur.user_id
where 1 = 1
<if test="departIds!=null and departIds!=''">
AND fu.depart_id in
<foreach item="item" index="index" collection="departIds.split(',')" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="userName!=null and userName!=''">
and fu.user_name like concat('%',#{userName},'%')
</if>
GROUP BY
fu.user_id
</select>
</mapper>
......
package com.skua.modules.system.service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.skua.modules.system.entity.SysFactoryUserInfo;
import com.baomidou.mybatisplus.extension.service.IService;
import com.skua.modules.system.entity.SysUser;
import java.util.List;
/**
* 厂站人员管理
*/
public interface ISysFactoryUserInfoService extends IService<SysFactoryUserInfo> {
IPage<SysFactoryUserInfo> getPage(Page<SysFactoryUserInfo> page, SysFactoryUserInfo sysFactoryUserInfo);
List<SysFactoryUserInfo> getList(SysFactoryUserInfo sysFactoryUserInfo);
SysFactoryUserInfo saveOrUpdateByUser(SysUser sysUser);
}
......
package com.skua.modules.system.service.impl;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.skua.core.context.BaseContextHandler;
import com.skua.modules.system.entity.SysFactoryUserInfo;
import com.skua.modules.system.entity.SysUser;
import com.skua.modules.system.mapper.SysFactoryUserInfoMapper;
import com.skua.modules.system.service.ISysFactoryUserInfoService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import java.util.ArrayList;
import java.util.List;
/**
* 厂站人员管理
*/
@Service
public class SysFactoryUserInfoServiceImpl extends ServiceImpl<SysFactoryUserInfoMapper, SysFactoryUserInfo> implements ISysFactoryUserInfoService {
@Autowired
private SysFactoryUserInfoMapper sysFactoryUserInfoMapper;
@Override
public IPage<SysFactoryUserInfo> getPage(Page<SysFactoryUserInfo> page, SysFactoryUserInfo sysFactoryUserInfo) {
List<SysFactoryUserInfo> list = getList(sysFactoryUserInfo);
page.setTotal(list.size());
page.setRecords(list);
return page;
}
@Override
public List<SysFactoryUserInfo> getList(SysFactoryUserInfo sysFactoryUserInfo) {
List<SysFactoryUserInfo> list = new ArrayList<>();
String departIds = BaseContextHandler.getDeparts();
if(StringUtils.isNotEmpty(sysFactoryUserInfo.getDepartId())){
departIds = sysFactoryUserInfo.getDepartId();
}
list = sysFactoryUserInfoMapper.getList(departIds,sysFactoryUserInfo.getUserName());
return list;
}
@Override
public SysFactoryUserInfo saveOrUpdateByUser(SysUser sysUser) {
return null;
}
}
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!