业务部门信息

This commit is contained in:
易焱 2019-07-31 01:49:55 +08:00
parent daa60cf523
commit 510b40573a
20 changed files with 93 additions and 53 deletions

3
.gitignore vendored
View File

@ -1,2 +1,3 @@
/.idea
/upload
/upload
**/target

View File

@ -27,7 +27,6 @@ import java.util.List;
* @author yan.y
* @date 2019/07/29
*/
@Controller("bssDeptController")
@RequestMapping("/bss/dept")
public class BssDeptController {

View File

@ -1,6 +1,7 @@
package com.cwhelp.admin.business.controller;
import com.cwhelp.admin.business.validator.BssPlatformValid;
import com.cwhelp.common.enums.ResultEnum;
import com.cwhelp.common.enums.StatusEnum;
import com.cwhelp.common.utils.EntityBeanUtil;
import com.cwhelp.common.utils.ResultVoUtil;
@ -58,24 +59,6 @@ public class BssPlatformController {
return "/business/platform/index";
}
/**
* 部门数据列表
*/
@GetMapping("/list")
@RequiresPermissions(value = {"bss:platform:index", "bss:dept:index"}, logical = Logical.OR)
@ResponseBody
public ResultVo list(BssPlatform bssPlatform) {
// 创建匹配器进行动态查询匹配
ExampleMatcher matcher = ExampleMatcher.matching()
.withMatcher("name", match -> match.contains());
// 获取部门列表
Example<BssPlatform> example = Example.of(bssPlatform, matcher);
Sort sort = new Sort(Sort.Direction.DESC, "createDate");
List<BssPlatform> list = bssPlatformService.getListByExample(example, sort);
return ResultVoUtil.success(list);
}
/**
* 跳转到添加页面
*/
@ -108,6 +91,21 @@ public class BssPlatformController {
BssPlatform beBssPlatform = bssPlatformService.getById(bssPlatform.getId());
EntityBeanUtil.copyProperties(beBssPlatform, bssPlatform);
}
// 校验手机号
boolean repeatByContactTel = bssPlatformService.repeatByContactTel(bssPlatform);
if (repeatByContactTel) {
return ResultVoUtil.error(ResultEnum.PLATFORM_EXIST_CONTACT_TEL.getCode(),ResultEnum.PLATFORM_EXIST_CONTACT_TEL.getMessage());
}
// 校验身份证号
boolean repeatByContactCard = bssPlatformService.repeatByContactCard(bssPlatform);
if (repeatByContactCard) {
return ResultVoUtil.error(ResultEnum.PLATFORM_EXIST_CONTACT_CARD.getCode(),ResultEnum.PLATFORM_EXIST_CONTACT_CARD.getMessage());
}
// 校验邮箱
boolean repeatByEmail = bssPlatformService.repeatByEmail(bssPlatform);
if (repeatByEmail) {
return ResultVoUtil.error(ResultEnum.PLATFORM_EXIST_EMAIL.getCode(),ResultEnum.PLATFORM_EXIST_EMAIL.getMessage());
}
// 保存数据
bssPlatformService.save(bssPlatform);

View File

@ -5,6 +5,7 @@ import lombok.Data;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import javax.validation.constraints.Size;
import java.io.Serializable;
@ -19,6 +20,9 @@ public class UserValid implements Serializable {
@Size(min = 2, message = "用户昵称请输入至少2个字符")
private String nickname;
private String confirm;
@Pattern(regexp = "^((17[0-9])|(14[0-9])|(13[0-9])|(15[^4,\\D])|(18[0,5-9]))\\d{8}$", message = "手机号码格式不正确")
@NotEmpty(message = "联系人电话不能为空")
private String phone;
@NotNull(message = "所在部门不能为空")
private Dept dept;
}

View File

@ -44,7 +44,6 @@
<label class="timo-checkbox"><input type="checkbox">
<i class="layui-icon layui-icon-ok"></i></label>
</th>
<th>主键ID</th>
<th>名称</th>
<th>所属</th>
<th class="sortable" data-field="createDate">创建时间</th>
@ -57,7 +56,6 @@
<tr th:each="item:${list}">
<td><label class="timo-checkbox"><input type="checkbox" th:value="${item.id}">
<i class="layui-icon layui-icon-ok"></i></label></td>
<td th:text="${item.id}">主键ID</td>
<td th:text="${item.name}">名称</td>
<td th:text="${item.bssPlatform.name}">所属平台</td>
<td th:text="${#dates.format(item.createDate, 'yyyy-MM-dd HH:mm:ss')}">创建时间</td>

View File

@ -39,7 +39,7 @@
<div class="layui-form-item">
<label class="layui-form-label required">类型</label>
<div class="layui-input-inline">
<select name="type" mo:dict="BSS_PLATFORM_TYPE" mo-selected="${menu?.type}" mo-empty="" lay-verify="type"></select>
<select name="type" mo:dict="BSS_PLATFORM_TYPE" mo-selected="${platform?.type}" mo-empty="" lay-verify="type"></select>
</div>
</div>
<div class="layui-form-item layui-form-text">

View File

@ -27,6 +27,13 @@ public enum ResultEnum implements ResultInterface {
USER_CAPTCHA_ERROR(406, "验证码错误"),
USER_PWD_STRENGTH_ERROR(407, "密码强度不够"),
/**
* 平台
*/
PLATFORM_EXIST_CONTACT_TEL(1001,"联系人手机号码已存在"),
PLATFORM_EXIST_CONTACT_CARD(1002,"联系人证件号码已存在"),
PLATFORM_EXIST_EMAIL(1003,"邮箱已存在"),
/**
* 角色问题
*/

View File

@ -3,7 +3,9 @@ package com.cwhelp.modules.business.domain;
import com.cwhelp.common.enums.StatusEnum;
import com.cwhelp.common.utils.StatusUtil;
import com.cwhelp.modules.system.domain.User;
import com.fasterxml.jackson.annotation.JsonIdentityInfo;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.ObjectIdGenerators;
import lombok.Data;
import org.hibernate.annotations.NotFound;
import org.hibernate.annotations.NotFoundAction;
@ -56,6 +58,7 @@ public class BssPlatform implements Serializable {
private Date updateDate;
// 创建者
@CreatedBy
@JsonIdentityInfo(generator = ObjectIdGenerators.IntSequenceGenerator.class,property = "@id")
@ManyToOne(fetch= FetchType.LAZY)
@NotFound(action=NotFoundAction.IGNORE)
@JoinColumn(name="create_by")
@ -63,6 +66,7 @@ public class BssPlatform implements Serializable {
private User createBy;
// 更新者
@LastModifiedBy
@JsonIdentityInfo(generator = ObjectIdGenerators.IntSequenceGenerator.class,property = "@id")
@ManyToOne(fetch=FetchType.LAZY)
@NotFound(action=NotFoundAction.IGNORE)
@JoinColumn(name="update_by")

View File

@ -8,5 +8,9 @@ import com.cwhelp.modules.system.repository.BaseRepository;
* @author yan.y
* @date 2019/07/28
*/
public interface BssPlatformRepository extends BaseRepository<BssPlatform, Long> {
public interface BssPlatformRepository extends BaseRepository<BssPlatform, Long>{
BssPlatform findByContactTelAndIdNot(String contactTel,Long id);
BssPlatform findByContactCardAndIdNot(String contactCard,Long id);
BssPlatform findByEmailAndIdNot(String email,Long id);
}

View File

@ -47,4 +47,9 @@ public interface BssPlatformService {
* @param sort 排序对象
*/
List<BssPlatform> getListByExample(Example<BssPlatform> example, Sort sort);
boolean repeatByContactTel(BssPlatform bssPlatform);
boolean repeatByContactCard(BssPlatform bssPlatform);
boolean repeatByEmail(BssPlatform bssPlatform);
}

View File

@ -75,4 +75,22 @@ public class BssPlatformServiceImpl implements BssPlatformService {
public List<BssPlatform> getListByExample(Example<BssPlatform> example, Sort sort) {
return bssPlatformRepository.findAll(example, sort);
}
@Override
public boolean repeatByContactTel(BssPlatform bssPlatform) {
Long id = bssPlatform.getId() != null ? bssPlatform.getId() : Long.MIN_VALUE;
return bssPlatformRepository.findByContactTelAndIdNot(bssPlatform.getContactTel(), id) != null;
}
@Override
public boolean repeatByContactCard(BssPlatform bssPlatform) {
Long id = bssPlatform.getId() != null ? bssPlatform.getId() : Long.MIN_VALUE;
return bssPlatformRepository.findByContactCardAndIdNot(bssPlatform.getContactCard(), id) != null;
}
@Override
public boolean repeatByEmail(BssPlatform bssPlatform) {
Long id = bssPlatform.getId() != null ? bssPlatform.getId() : Long.MIN_VALUE;
return bssPlatformRepository.findByEmailAndIdNot(bssPlatform.getEmail(), id) != null;
}
}

View File

@ -1,10 +1,12 @@
package com.cwhelp.modules.system.domain;
import com.fasterxml.jackson.annotation.JsonIdentityInfo;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.cwhelp.common.enums.StatusEnum;
import com.cwhelp.common.utils.StatusUtil;
import com.cwhelp.component.excel.annotation.Excel;
import com.cwhelp.component.excel.enums.ExcelType;
import com.fasterxml.jackson.annotation.ObjectIdGenerators;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.SQLDelete;
@ -59,7 +61,7 @@ public class User implements Serializable {
@Excel(value = "状态", dict = "DATA_STATUS")
private Byte status = StatusEnum.OK.getCode();
@ManyToOne(fetch=FetchType.EAGER)
@ManyToOne(fetch=FetchType.LAZY)
@JoinColumn(name="dept_id")
@JsonIgnore
private Dept dept;

View File

@ -12,5 +12,5 @@ public interface ActionLogRepository extends JpaRepository<ActionLog, Long> {
* @param model 模型表名
* @param recordId 数据ID
*/
public List<ActionLog> findByModelAndRecordId(String model, Long recordId);
List<ActionLog> findByModelAndRecordId(String model, Long recordId);
}

View File

@ -20,7 +20,7 @@ public interface BaseRepository<T, ID> extends JpaRepository<T,ID> {
* @param id 主键ID
* @param status 状态
*/
public T findByIdAndStatus(Long id, Byte status);
T findByIdAndStatus(Long id, Byte status);
/**
* 批量更新数据状态
@ -32,5 +32,5 @@ public interface BaseRepository<T, ID> extends JpaRepository<T,ID> {
@Modifying
@Transactional
@Query("update #{#entityName} set status = ?1 where id in ?2 and status <> " + StatusConst.DELETE)
public Integer updateStatus(Byte status, List<Long> id);
Integer updateStatus(Byte status, List<Long> id);
}

View File

@ -16,20 +16,20 @@ public interface DeptRepository extends BaseRepository<Dept, Long> {
* 查找多个部门
* @param ids id列表
*/
public List<Dept> findByIdIn(List<Long> ids);
List<Dept> findByIdIn(List<Long> ids);
/**
* 获取排序最大值
* @param pid 父部门ID
*/
@Query("select max(sort) from Menu m where m.pid = ?1 and m.status <> " + StatusConst.DELETE)
public Integer findSortMax(long pid);
Integer findSortMax(long pid);
/**
* 根据父ID查找子孙部门
* @param pids pid列表
*/
public List<Dept> findByPidsLikeAndStatus(String pids, Byte status);
List<Dept> findByPidsLikeAndStatus(String pids, Byte status);
/**
* 根据父级部门ID获取本级全部部门
@ -37,6 +37,6 @@ public interface DeptRepository extends BaseRepository<Dept, Long> {
* @param pid 父部门ID
* @param notId 需要排除的部门ID
*/
public List<Dept> findByPidAndIdNot(Sort sort, long pid, long notId);
List<Dept> findByPidAndIdNot(Sort sort, long pid, long notId);
}

View File

@ -12,12 +12,12 @@ public interface DictRepository extends BaseRepository<Dict, Long> {
* @param name 字典标识
* @param status 状态
*/
public Dict findByNameAndStatus(String name, Byte status);
Dict findByNameAndStatus(String name, Byte status);
/**
* 根据标识查询字典数据,且排查指定ID的字典
* @param name 字典标识
* @param id 字典ID
*/
public Dict findByNameAndIdNot(String name, Long id);
Dict findByNameAndIdNot(String name, Long id);
}

View File

@ -18,32 +18,32 @@ public interface MenuRepository extends BaseRepository<Menu, Long> {
* 查找多个菜单
* @param ids id列表
*/
public List<Menu> findByIdIn(List<Long> ids);
List<Menu> findByIdIn(List<Long> ids);
/**
* 查找响应状态的菜单
* @param sort 排序对象
*/
public List<Menu> findAllByStatus(Sort sort, Byte status);
List<Menu> findAllByStatus(Sort sort, Byte status);
/**
* 查询菜单URL
* @param url id列表
*/
public Menu findByUrl(String url);
Menu findByUrl(String url);
/**
* 根据父ID查找子菜单
* @param pids pid列表
*/
public List<Menu> findByPidsLikeAndStatus(String pids, Byte status);
List<Menu> findByPidsLikeAndStatus(String pids, Byte status);
/**
* 获取排序最大值
* @param pid 父菜单ID
*/
@Query("select max(sort) from Menu m where m.pid = ?1 and m.status <> " + StatusConst.DELETE)
public Integer findSortMax(long pid);
Integer findSortMax(long pid);
/**
* 根据父级菜单ID获取本级全部菜单
@ -51,7 +51,7 @@ public interface MenuRepository extends BaseRepository<Menu, Long> {
* @param pid 父菜单ID
* @param notId 需要排除的菜单ID
*/
public List<Menu> findByPidAndIdNot(Sort sort, long pid, long notId);
List<Menu> findByPidAndIdNot(Sort sort, long pid, long notId);
/**
* 取消菜单与角色之间的关系
@ -60,5 +60,5 @@ public interface MenuRepository extends BaseRepository<Menu, Long> {
@Modifying
@Transactional
@Query(value = "DELETE FROM sys_role_menu WHERE menu_id = ?1", nativeQuery = true)
public Integer cancelRoleJoin(Long id);
Integer cancelRoleJoin(Long id);
}

View File

@ -18,34 +18,34 @@ public interface RoleRepository extends BaseRepository<Role,Long> {
* 查找多个角色
* @param ids id列表
*/
public List<Role> findByIdIn(List<Long> ids);
List<Role> findByIdIn(List<Long> ids);
/**
* 查找相应状态的角色
* @param sort 排序对象
*/
public List<Role> findAllByStatus(Sort sort, Byte status);
List<Role> findAllByStatus(Sort sort, Byte status);
/**
* 查询指定用户的角色列表
* @param id 用户ID
* @param status 角色状态
*/
public Set<Role> findByUsers_IdAndStatus(Long id, Byte status);
Set<Role> findByUsers_IdAndStatus(Long id, Byte status);
/**
* 根据标识查询角色数据,且排查指定ID的角色
* @param name 角色标识
* @param id 角色ID
*/
public Role findByNameAndIdNot(String name, Long id);
Role findByNameAndIdNot(String name, Long id);
/**
* 判断指定的用户是否存在角色
* @param id 用户ID
* @param status 角色状态
*/
public Boolean existsByUsers_IdAndStatus(Long id, Byte status);
Boolean existsByUsers_IdAndStatus(Long id, Byte status);
/**
* 取消角色与用户之间的关系
@ -54,7 +54,7 @@ public interface RoleRepository extends BaseRepository<Role,Long> {
@Modifying
@Transactional
@Query(value = "DELETE FROM sys_user_role WHERE role_id in ?1", nativeQuery = true)
public Integer cancelUserJoin(List<Long> ids);
Integer cancelUserJoin(List<Long> ids);
/**
* 取消角色与菜单之间的关系
@ -63,6 +63,6 @@ public interface RoleRepository extends BaseRepository<Role,Long> {
@Modifying
@Transactional
@Query(value = "DELETE FROM sys_role_menu WHERE role_id in ?1", nativeQuery = true)
public Integer cancelMenuJoin(List<Long> ids);
Integer cancelMenuJoin(List<Long> ids);
}

View File

@ -12,6 +12,6 @@ public interface UploadRepository extends JpaRepository<Upload, Long> {
* 查找指定文件sha1记录
* @param sha1 文件sha1值
*/
public Upload findBySha1(String sha1);
Upload findBySha1(String sha1);
}

View File

@ -16,7 +16,7 @@ public interface UserRepository extends BaseRepository<User, Long>, JpaSpecifica
* @param username 用户名
* @return 用户数据
*/
public User findByUsername(String username);
User findByUsername(String username);
/**
* 根据用户名查询用户数据,且排查指定ID的用户
@ -24,16 +24,16 @@ public interface UserRepository extends BaseRepository<User, Long>, JpaSpecifica
* @param id 排除的用户ID
* @return 用户数据
*/
public User findByUsernameAndIdNot(String username, Long id);
User findByUsernameAndIdNot(String username, Long id);
/**
* 查找多个相应部门的用户列表
*/
public List<User> findByDept(Dept dept);
List<User> findByDept(Dept dept);
/**
* 删除多条数据
* @param ids ID列表
*/
public Integer deleteByIdIn(List<Long> ids);
Integer deleteByIdIn(List<Long> ids);
}