diff --git a/zt-admin/src/main/java/com/wuzhen/web/controller/system/ActiveInfoController.java b/zt-admin/src/main/java/com/wuzhen/web/controller/busi/ActiveInfoController.java similarity index 57% rename from zt-admin/src/main/java/com/wuzhen/web/controller/system/ActiveInfoController.java rename to zt-admin/src/main/java/com/wuzhen/web/controller/busi/ActiveInfoController.java index 72458e403..4239ac409 100644 --- a/zt-admin/src/main/java/com/wuzhen/web/controller/system/ActiveInfoController.java +++ b/zt-admin/src/main/java/com/wuzhen/web/controller/busi/ActiveInfoController.java @@ -1,91 +1,85 @@ -//package com.wuzhen.web.controller.system; -// -//import com.wuzhen.common.annotation.Log; -//import com.wuzhen.common.constant.UserConstants; -//import com.wuzhen.common.core.controller.BaseController; -//import com.wuzhen.common.core.domain.AjaxResult; -//import com.wuzhen.common.core.domain.entity.SysRole; -//import com.wuzhen.common.core.domain.entity.SysUser; -//import com.wuzhen.common.core.page.TableDataInfo; -//import com.wuzhen.common.enums.BusinessType; -//import com.wuzhen.common.utils.poi.ExcelUtil; -//import com.wuzhen.framework.shiro.util.AuthorizationUtils; -//import com.wuzhen.system.domain.SysUserRole; -//import com.wuzhen.system.service.ISysRoleService; -//import com.wuzhen.system.service.ISysUserService; -//import org.apache.shiro.authz.annotation.RequiresPermissions; -//import org.springframework.beans.factory.annotation.Autowired; -//import org.springframework.stereotype.Controller; -//import org.springframework.ui.ModelMap; -//import org.springframework.validation.annotation.Validated; -//import org.springframework.web.bind.annotation.*; -// -//import java.util.List; -// -///** -// * 角色信息 -// * -// * @author zhengzheng -// */ -//@Controller -//@RequestMapping("/system/role") -//public class ActiveInfoController extends BaseController -//{ -// private String prefix = "system/role"; -// -// @Autowired -// private ISysRoleService roleService; -// -// @Autowired -// private ISysUserService userService; -// -// @RequiresPermissions("system:role:view") -// @GetMapping() -// public String role() -// { -// return prefix + "/role"; -// } -// -// @RequiresPermissions("system:role:list") -// @PostMapping("/list") -// @ResponseBody -// public TableDataInfo list(SysRole role) -// { -// startPage(); -// List list = roleService.selectRoleList(role); -// return getDataTable(list); -// } -// -// @Log(title = "角色管理", businessType = BusinessType.EXPORT) -// @RequiresPermissions("system:role:export") -// @PostMapping("/export") -// @ResponseBody -// public AjaxResult export(SysRole role) -// { -// List list = roleService.selectRoleList(role); -// ExcelUtil util = new ExcelUtil(SysRole.class); -// return util.exportExcel(list, "角色数据"); -// } -// -// /** -// * 新增角色 -// */ -// @GetMapping("/add") -// public String add() -// { -// return prefix + "/add"; -// } -// -// /** -// * 新增保存角色 -// */ -// @RequiresPermissions("system:role:add") -// @Log(title = "角色管理", businessType = BusinessType.INSERT) -// @PostMapping("/add") -// @ResponseBody -// public AjaxResult addSave(@Validated SysRole role) -// { -// if (UserConstants.ROLE_NAME_NOT_UNIQUE.equals(roleService.checkRoleNameUnique(role))) +package com.wuzhen.web.controller.busi; + +import com.wuzhen.common.annotation.Log; +import com.wuzhen.common.core.controller.BaseController; +import com.wuzhen.common.core.domain.AjaxResult; +import com.wuzhen.common.core.page.TableDataInfo; +import com.wuzhen.common.enums.BusinessType; +import com.wuzhen.common.utils.poi.ExcelUtil; +import com.wuzhen.framework.shiro.util.AuthorizationUtils; +import com.wuzhen.system.domain.ActiveInfo; +import com.wuzhen.system.service.IActiveInfoService; +import org.apache.shiro.authz.annotation.RequiresPermissions; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.ui.ModelMap; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; +import java.util.List; + +/** + * 角色信息 + * + * @author zhengzheng + */ +@Controller +@RequestMapping("/active/info") +public class ActiveInfoController extends BaseController +{ + private String prefix = "active/info"; + + @Autowired + private IActiveInfoService activeInfoService; + + + + @RequiresPermissions("active:info:view") + @GetMapping() + public String role() + { + return prefix + "/index"; + } + + @RequiresPermissions("active:info:list") + @PostMapping("/list") + @ResponseBody + public TableDataInfo list(ActiveInfo activeInfo) + { + startPage(); + List list = activeInfoService.selectActiveList(activeInfo); + return getDataTable(list); + } + + @Log(title = "活动信息导出", businessType = BusinessType.EXPORT) + @RequiresPermissions("active:info:export") + @PostMapping("/export") + @ResponseBody + public AjaxResult export(ActiveInfo activeInfo) + { + List list = activeInfoService.selectActiveList(activeInfo); + ExcelUtil util = new ExcelUtil(ActiveInfo.class); + return util.exportExcel(list, "活动信息"); + } + + /** + * 新增活动 + */ + @GetMapping("/add") + public String add() + { + return prefix + "/add"; + } + + /** + * 新增保存活动 + */ + @RequiresPermissions("active:info:add") + @Log(title = "活动管理", businessType = BusinessType.INSERT) + @PostMapping("/add") + @ResponseBody + public AjaxResult addSave(@Validated ActiveInfo activeInfo) + { +// if (UserConstants.ROLE_NAME_NOT_UNIQUE.equals(activeInfoService.checkNameUnique(role))) // { // return error("新增角色'" + role.getRoleName() + "'失败,角色名称已存在"); // } @@ -93,33 +87,33 @@ // { // return error("新增角色'" + role.getRoleName() + "'失败,角色权限已存在"); // } -// role.setCreateBy(getLoginName()); -// AuthorizationUtils.clearAllCachedAuthorizationInfo(); -// return toAjax(roleService.insertRole(role)); -// -// } -// -// /** -// * 修改角色 -// */ -// @RequiresPermissions("system:role:edit") -// @GetMapping("/edit/{roleId}") -// public String edit(@PathVariable("roleId") Long roleId, ModelMap mmap) -// { + activeInfo.setCreateBy(getLoginName()); + AuthorizationUtils.clearAllCachedAuthorizationInfo(); + return toAjax(activeInfoService.insertActive(activeInfo)); + + } + + /** + * 修改活动 + */ + @RequiresPermissions("active:info:edit") + @GetMapping("/edit/{id}") + public String edit(@PathVariable("id") Long id, ModelMap mmap) + { // roleService.checkRoleDataScope(roleId); -// mmap.put("role", roleService.selectRoleById(roleId)); -// return prefix + "/edit"; -// } -// -// /** -// * 修改保存角色 -// */ -// @RequiresPermissions("system:role:edit") -// @Log(title = "角色管理", businessType = BusinessType.UPDATE) -// @PostMapping("/edit") -// @ResponseBody -// public AjaxResult editSave(@Validated SysRole role) -// { + mmap.put("active", activeInfoService.selectActiveById(id)); + return prefix + "/edit"; + } + + /** + * 修改保存活动 + */ + @RequiresPermissions("active:info:edit") + @Log(title = "角色管理", businessType = BusinessType.UPDATE) + @PostMapping("/edit") + @ResponseBody + public AjaxResult editSave(@Validated ActiveInfo activeInfo) + { // roleService.checkRoleAllowed(role); // roleService.checkRoleDataScope(role.getRoleId()); // if (UserConstants.ROLE_NAME_NOT_UNIQUE.equals(roleService.checkRoleNameUnique(role))) @@ -130,11 +124,11 @@ // { // return error("修改角色'" + role.getRoleName() + "'失败,角色权限已存在"); // } -// role.setUpdateBy(getLoginName()); -// AuthorizationUtils.clearAllCachedAuthorizationInfo(); -// return toAjax(roleService.updateRole(role)); -// } -// + activeInfo.setUpdateBy(getLoginName()); + AuthorizationUtils.clearAllCachedAuthorizationInfo(); + return toAjax(activeInfoService.updateActive(activeInfo)); + } + // /** // * 角色分配数据权限 // */ @@ -144,7 +138,7 @@ // mmap.put("role", roleService.selectRoleById(roleId)); // return prefix + "/dataScope"; // } -// + // /** // * 保存角色分配数据权限 // */ @@ -164,17 +158,17 @@ // } // return error(); // } -// -// @RequiresPermissions("system:role:remove") -// @Log(title = "角色管理", businessType = BusinessType.DELETE) -// @PostMapping("/remove") -// @ResponseBody -// public AjaxResult remove(String ids) -// { -// return toAjax(roleService.deleteRoleByIds(ids)); -// } -// -// /** + + @RequiresPermissions("active:info:remove") + @Log(title = "活动管理", businessType = BusinessType.DELETE) + @PostMapping("/remove") + @ResponseBody + public AjaxResult remove(String ids) + { + return toAjax(activeInfoService.deleteActiveByIds(ids)); + } + + /** // * 校验角色名称 // */ // @PostMapping("/checkRoleNameUnique") @@ -202,7 +196,7 @@ // { // return prefix + "/tree"; // } -// + // /** // * 角色状态修改 // */ @@ -216,7 +210,7 @@ // roleService.checkRoleDataScope(role.getRoleId()); // return toAjax(roleService.changeStatus(role)); // } -// + // /** // * 分配用户 // */ @@ -227,7 +221,7 @@ // mmap.put("role", roleService.selectRoleById(roleId)); // return prefix + "/authUser"; // } -// + // /** // * 查询已分配用户角色列表 // */ @@ -240,7 +234,7 @@ // List list = userService.selectAllocatedList(user); // return getDataTable(list); // } -// + // /** // * 取消授权 // */ @@ -252,10 +246,10 @@ // { // return toAjax(roleService.deleteAuthUser(userRole)); // } -// -// /** -// * 批量取消授权 -// */ + + /** + * 批量取消授权 + */ // @RequiresPermissions("system:role:edit") // @Log(title = "角色管理", businessType = BusinessType.GRANT) // @PostMapping("/authUser/cancelAll") @@ -264,7 +258,7 @@ // { // return toAjax(roleService.deleteAuthUsers(roleId, userIds)); // } -// + // /** // * 选择用户 // */ @@ -274,7 +268,7 @@ // mmap.put("role", roleService.selectRoleById(roleId)); // return prefix + "/selectUser"; // } -// + // /** // * 查询未分配用户角色列表 // */ @@ -287,7 +281,7 @@ // List list = userService.selectUnallocatedList(user); // return getDataTable(list); // } -// + // /** // * 批量选择用户授权 // */ @@ -300,4 +294,4 @@ // roleService.checkRoleDataScope(roleId); // return toAjax(roleService.insertAuthUsers(roleId, userIds)); // } -//} \ No newline at end of file +} \ No newline at end of file diff --git a/zt-admin/src/main/java/com/wuzhen/web/controller/system/ActiveUserController.java b/zt-admin/src/main/java/com/wuzhen/web/controller/busi/ActiveUserController.java similarity index 98% rename from zt-admin/src/main/java/com/wuzhen/web/controller/system/ActiveUserController.java rename to zt-admin/src/main/java/com/wuzhen/web/controller/busi/ActiveUserController.java index cdd7b2fb0..6488cca0f 100644 --- a/zt-admin/src/main/java/com/wuzhen/web/controller/system/ActiveUserController.java +++ b/zt-admin/src/main/java/com/wuzhen/web/controller/busi/ActiveUserController.java @@ -1,4 +1,4 @@ -//package com.wuzhen.web.controller.system; +package com.wuzhen.web.controller.busi;//package com.wuzhen.web.controller.system; // //import com.wuzhen.common.annotation.Log; //import com.wuzhen.common.constant.UserConstants; diff --git a/zt-admin/src/main/java/com/wuzhen/web/controller/system/EnrollUserController.java b/zt-admin/src/main/java/com/wuzhen/web/controller/busi/EnrollUserController.java similarity index 99% rename from zt-admin/src/main/java/com/wuzhen/web/controller/system/EnrollUserController.java rename to zt-admin/src/main/java/com/wuzhen/web/controller/busi/EnrollUserController.java index a412e6dcb..10b02ad28 100644 --- a/zt-admin/src/main/java/com/wuzhen/web/controller/system/EnrollUserController.java +++ b/zt-admin/src/main/java/com/wuzhen/web/controller/busi/EnrollUserController.java @@ -1,4 +1,4 @@ -package com.wuzhen.web.controller.system; +package com.wuzhen.web.controller.busi; import com.wuzhen.common.annotation.Log; import com.wuzhen.common.core.controller.BaseController; diff --git a/zt-admin/src/main/java/com/wuzhen/web/controller/monitor/DruidController.java b/zt-admin/src/main/java/com/wuzhen/web/controller/monitor/DruidController.java index 5b1fc71c1..c8696a067 100644 --- a/zt-admin/src/main/java/com/wuzhen/web/controller/monitor/DruidController.java +++ b/zt-admin/src/main/java/com/wuzhen/web/controller/monitor/DruidController.java @@ -21,6 +21,6 @@ public class DruidController extends BaseController @GetMapping() public String index() { - return redirect(prefix + "/index.html"); + return redirect(prefix + "/edit.html"); } } diff --git a/zt-admin/src/main/java/com/wuzhen/web/controller/tool/SwaggerController.java b/zt-admin/src/main/java/com/wuzhen/web/controller/tool/SwaggerController.java index e77698978..907b000ac 100644 --- a/zt-admin/src/main/java/com/wuzhen/web/controller/tool/SwaggerController.java +++ b/zt-admin/src/main/java/com/wuzhen/web/controller/tool/SwaggerController.java @@ -19,6 +19,6 @@ public class SwaggerController extends BaseController @GetMapping() public String index() { - return redirect("/swagger-ui/index.html"); + return redirect("/swagger-ui/edit.html"); } } diff --git a/zt-admin/src/main/resources/templates/active/authUser.html b/zt-admin/src/main/resources/templates/active/authUser.html new file mode 100644 index 000000000..0bce4078f --- /dev/null +++ b/zt-admin/src/main/resources/templates/active/authUser.html @@ -0,0 +1,142 @@ + + + + + + +
+
+
+
+ +
+ +
+
+
+ + + +
+
+
+
+
+ + + + \ No newline at end of file diff --git a/zt-admin/src/main/resources/templates/active/dataScope.html b/zt-admin/src/main/resources/templates/active/dataScope.html new file mode 100644 index 000000000..45d363305 --- /dev/null +++ b/zt-admin/src/main/resources/templates/active/dataScope.html @@ -0,0 +1,137 @@ + + + + + + + +
+
+ +
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ + 特殊情况下,设置为“自定数据权限” +
+
+
+ +
+ + + +
+
+
+
+
+ + + + + diff --git a/zt-admin/src/main/resources/templates/active/info/add.html b/zt-admin/src/main/resources/templates/active/info/add.html new file mode 100644 index 000000000..89414a17f --- /dev/null +++ b/zt-admin/src/main/resources/templates/active/info/add.html @@ -0,0 +1,92 @@ + + + + + + + +
+
+
+ +
+ +
+
+
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+ +
+
+ + + + + diff --git a/zt-admin/src/main/resources/templates/active/info/edit.html b/zt-admin/src/main/resources/templates/active/info/edit.html new file mode 100644 index 000000000..3518f30ac --- /dev/null +++ b/zt-admin/src/main/resources/templates/active/info/edit.html @@ -0,0 +1,109 @@ + + + + + + + +
+
+ +
+ +
+ +
+
+
+ + +
+ +
+ +
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+ +
+
+ + + + diff --git a/zt-admin/src/main/resources/templates/active/info/index.html b/zt-admin/src/main/resources/templates/active/info/index.html new file mode 100644 index 000000000..9e84d92e0 --- /dev/null +++ b/zt-admin/src/main/resources/templates/active/info/index.html @@ -0,0 +1,164 @@ + + + + + + +
+
+
+
+
+
    +
  • + 活动标题: +
  • +
  • + 互动状态: +
  • +
  • + + + - + +
  • +
  • +  搜索 +  重置 +
  • +
+
+
+
+ + + +
+
+
+
+
+ + + + \ No newline at end of file diff --git a/zt-admin/src/main/resources/templates/active/selectUser.html b/zt-admin/src/main/resources/templates/active/selectUser.html new file mode 100644 index 000000000..e96406202 --- /dev/null +++ b/zt-admin/src/main/resources/templates/active/selectUser.html @@ -0,0 +1,113 @@ + + + + + + + +
+
+
+
+ +
+ +
+
+
+ +
+
+
+
+
+ + + + \ No newline at end of file diff --git a/zt-system/src/main/java/com/wuzhen/system/domain/ActiveInfo.java b/zt-system/src/main/java/com/wuzhen/system/domain/ActiveInfo.java new file mode 100644 index 000000000..65f943c48 --- /dev/null +++ b/zt-system/src/main/java/com/wuzhen/system/domain/ActiveInfo.java @@ -0,0 +1,163 @@ +package com.wuzhen.system.domain; + +import com.fasterxml.jackson.annotation.JsonFormat; +import com.wuzhen.common.annotation.Excel; +import com.wuzhen.common.annotation.Excel.ColumnType; +import com.wuzhen.common.core.domain.BaseEntity; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; + +/** + * 活动信息 active_info + * + * @author zhengzheng + */ +public class ActiveInfo extends BaseEntity { + private static final long serialVersionUID = 1L; + + /** + * 活动编号 + */ + @Excel(name = "报名用户编号", cellType = ColumnType.NUMERIC) + private Long id; + + + /** + * 活动标题 + */ + @Excel(name = "活动标题") + private String activeTitle; + + + /** + * 活动内容描述 + */ + @Excel(name = "活动内容描述") + private String activeDesc; + + /** + * 活动开始日期 + */ + @JsonFormat(pattern = "yyyy-MM-dd") + @Excel(name = "活动开始日期") + private String activeStartDate; + + /** + * 活动结束日期 + */ + @JsonFormat(pattern = "yyyy-MM-dd") + @Excel(name = "活动结束日期") + private String activeEndDate; + + /** + * 海报地址 + */ + @Excel(name = "活动类型") + private String activeType; + + /** + * 活动图片 + */ + @Excel(name = "活动图片") + private String activePic; + + /** + * 推荐人编号 + */ + @Excel(name = "活动状态") + private String status; + + /** 删除标志(0代表存在 2代表删除) */ + private String delFlag; + + public String getDelFlag() { + return delFlag; + } + + public void setDelFlag(String delFlag) { + this.delFlag = delFlag; + } + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getActiveTitle() { + return activeTitle; + } + + public void setActiveTitle(String activeTitle) { + this.activeTitle = activeTitle; + } + + public String getActiveDesc() { + return activeDesc; + } + + public void setActiveDesc(String activeDesc) { + this.activeDesc = activeDesc; + } + + public String getActiveStartDate() { + return activeStartDate; + } + + public void setActiveStartDate(String activeStartDate) { + this.activeStartDate = activeStartDate; + } + + public String getActiveEndDate() { + return activeEndDate; + } + + public void setActiveEndDate(String activeEndDate) { + this.activeEndDate = activeEndDate; + } + + public String getActiveType() { + return activeType; + } + + public void setActiveType(String activeType) { + this.activeType = activeType; + } + + public String getActivePic() { + return activePic; + } + + public void setActivePic(String activePic) { + this.activePic = activePic; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + @Override + public String toString() { + return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE) + .append("id", getId()) + .append("activeTitle", getActiveTitle()) + .append("activeDesc", getActiveDesc()) + .append("activeStartDate", getActiveStartDate()) + .append("activeEndDate", getActiveEndDate()) + .append("activeType", getActiveType()) + .append("activePic", getActivePic()) + .append("createBy", getCreateBy()) + .append("createTime", getCreateTime()) + .append("updateBy", getUpdateBy()) + .append("updateTime", getUpdateTime()) + .append("remark", getRemark()) + .toString(); + } + +} diff --git a/zt-system/src/main/java/com/wuzhen/system/mapper/ActiveInfoMapper.java b/zt-system/src/main/java/com/wuzhen/system/mapper/ActiveInfoMapper.java new file mode 100644 index 000000000..1c5d99923 --- /dev/null +++ b/zt-system/src/main/java/com/wuzhen/system/mapper/ActiveInfoMapper.java @@ -0,0 +1,65 @@ +package com.wuzhen.system.mapper; + +import com.wuzhen.system.domain.ActiveInfo; + +import java.util.List; + +/** + * 角色表 数据层 + * + * @author zhengzheng + */ +public interface ActiveInfoMapper +{ + /** + * 根据条件分页查询角色数据 + * + * @param activeInfo 活动信息 + * @return 活动数据集合信息 + */ + public List selectActiveList(ActiveInfo activeInfo); + + + + /** + * 通过活动ID查询角色 + * + * @param id ID + * @return 角色对象信息 + */ + public ActiveInfo selectActiveById(Long id); + + /** + * 通过角色ID删除角色 + * + * @param id 角色ID + * @return 结果 + */ + public int deleteActiveById(Long id); + + /** + * 批量活动信息 + * + * @param ids 需要删除的数据ID + * @return 结果 + */ + public int deleteActiveByIds(Long[] ids); + + /** + * 修改角色信息 + * + * @param activeInfo 角色信息 + * @return 结果 + */ + public int updateActive(ActiveInfo activeInfo); + + /** + * 新增角色信息 + * + * @param activeInfo 角色信息 + * @return 结果 + */ + public int insertActive(ActiveInfo activeInfo); + + +} diff --git a/zt-system/src/main/java/com/wuzhen/system/service/IActiveInfoService.java b/zt-system/src/main/java/com/wuzhen/system/service/IActiveInfoService.java new file mode 100644 index 000000000..36009217f --- /dev/null +++ b/zt-system/src/main/java/com/wuzhen/system/service/IActiveInfoService.java @@ -0,0 +1,72 @@ +package com.wuzhen.system.service; + +import com.wuzhen.system.domain.ActiveInfo; + +import java.util.List; + +/** + * 活动信息服务层 + * + * @author zhengzheng + */ +public interface IActiveInfoService +{ + /** + * 根据条件分页查询角色数据 + * + * @param activeInfo 活动信息 + * @return 活动数据集合信息 + */ + public List selectActiveList(ActiveInfo activeInfo); + + + /** + * 查询所有角色 + * + * @return 角色列表 + */ + public List selectActiveAll(); + + /** + * 通过角色ID查询角色 + * + * @param id 活动ID + * @return 角色对象信息 + */ + public ActiveInfo selectActiveById(Long id); + + /** + * 通过活动ID删除角色 + * + * @param id 角色ID + * @return 结果 + */ + public boolean deleteActiveById(Long id); + + /** + * 批量删除角色用户信息 + * + * @param ids 需要删除的数据ID + * @return 结果 + * @throws Exception 异常 + */ + public int deleteActiveByIds(String ids); + + /** + * 新增保存角色信息 + * + * @param activeInfo 角色信息 + * @return 结果 + */ + public int insertActive(ActiveInfo activeInfo); + + /** + * 修改保存角色信息 + * + * @param activeInfo 角色信息 + * @return 结果 + */ + public int updateActive(ActiveInfo activeInfo); + + +} diff --git a/zt-system/src/main/java/com/wuzhen/system/service/impl/ActiveInfoServiceImpl.java b/zt-system/src/main/java/com/wuzhen/system/service/impl/ActiveInfoServiceImpl.java new file mode 100644 index 000000000..9445267b9 --- /dev/null +++ b/zt-system/src/main/java/com/wuzhen/system/service/impl/ActiveInfoServiceImpl.java @@ -0,0 +1,354 @@ +package com.wuzhen.system.service.impl; + +import com.wuzhen.common.annotation.DataScope; +import com.wuzhen.common.core.text.Convert; +import com.wuzhen.common.utils.spring.SpringUtils; +import com.wuzhen.system.domain.ActiveInfo; +import com.wuzhen.system.mapper.ActiveInfoMapper; +import com.wuzhen.system.service.IActiveInfoService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import java.util.List; + +/** + * 角色 业务层处理 + * + * @author zhengzheng + */ +@Service +public class ActiveInfoServiceImpl implements IActiveInfoService { + @Autowired + private ActiveInfoMapper activeInfoMapper; + + + /** + * 根据条件分页查询角色数据 + * + * @param activeInfo 角色信息 + * @return 角色数据集合信息 + */ + @Override + @DataScope(deptAlias = "d") + public List selectActiveList(ActiveInfo activeInfo) { + return activeInfoMapper.selectActiveList(activeInfo); + } + +// /** +// * 根据用户ID查询权限 +// * +// * @param userId 用户ID +// * @return 权限列表 +// */ +// @Override +// public Set selectRoleKeys(Long userId) +// { +// List perms = roleMapper.selectRolesByUserId(userId); +// Set permsSet = new HashSet<>(); +// for (SysRole perm : perms) +// { +// if (StringUtils.isNotNull(perm)) +// { +// permsSet.addAll(Arrays.asList(perm.getRoleKey().trim().split(","))); +// } +// } +// return permsSet; +// } + +// /** +// * 根据用户ID查询角色 +// * +// * @param userId 用户ID +// * @return 角色列表 +// */ +// @Override +// public List selectRolesByUserId(Long userId) +// { +// List userRoles = roleMapper.selectRolesByUserId(userId); +// List roles = selectRoleAll(); +// for (SysRole role : roles) +// { +// for (SysRole userRole : userRoles) +// { +// if (role.getRoleId().longValue() == userRole.getRoleId().longValue()) +// { +// role.setFlag(true); +// break; +// } +// } +// } +// return roles; +// } + + /** + * 查询所有角色 + * + * @return 角色列表 + */ + @Override + public List selectActiveAll() { + return SpringUtils.getAopProxy(this).selectActiveList(new ActiveInfo()); + } + + /** + * 通过活动ID查询角色 + * + * @param id 活动ID + * @return 活动对象信息 + */ + @Override + public ActiveInfo selectActiveById(Long id) { + return activeInfoMapper.selectActiveById(id); + } + + /** + * 通过角色ID删除角色 + * + * @param id 角色ID + * @return 结果 + */ + @Override + @Transactional + public boolean deleteActiveById(Long id) { + return activeInfoMapper.deleteActiveById(id) > 0 ? true : false; + } + + /** + * 批量删除角色信息 + * + * @param ids 需要删除的数据ID + * @throws Exception + */ + @Override + @Transactional + public int deleteActiveByIds(String ids) { + Long[] ids_arr = Convert.toLongArray(ids); +// for (Long roleId : roleIds) { +// checkRoleAllowed(new SysRole(roleId)); +// checkRoleDataScope(roleId); +// SysRole role = selectRoleById(roleId); +// if (countUserRoleByRoleId(roleId) > 0) { +// throw new ServiceException(String.format("%1$s已分配,不能删除", role.getRoleName())); +// } +// } +// // 删除角色与菜单关联 +// roleMenuMapper.deleteRoleMenu(roleIds); +// // 删除角色与部门关联 +// roleDeptMapper.deleteRoleDept(roleIds); + return activeInfoMapper.deleteActiveByIds(ids_arr); + } + + /** + * 新增保存角色信息 + * + * @param activeInfo 角色信息 + * @return 结果 + */ + @Override + @Transactional + public int insertActive(ActiveInfo activeInfo) { + // 新增角色信息 +// activeInfoMapper.insertActive(activeInfo); + return activeInfoMapper.insertActive(activeInfo); + } + + /** + * 修改保存活动信息 + * + * @param activeInfo 活动信息 + * @return 结果 + */ + @Override + @Transactional + public int updateActive(ActiveInfo activeInfo) { + // 修改角色信息 + activeInfoMapper.updateActive(activeInfo); + return activeInfoMapper.updateActive(activeInfo); + } + + /** + * 修改数据权限信息 + * + * @param role 角色信息 + * @return 结果 + */ +// @Override +// @Transactional +// public int authDataScope(SysRole role) { +// // 修改角色信息 +// roleMapper.updateRole(role); +// // 删除角色与部门关联 +// roleDeptMapper.deleteRoleDeptByRoleId(role.getRoleId()); +// // 新增角色和部门信息(数据权限) +// return insertRoleDept(role); +// } +// +// /** +// * 新增角色菜单信息 +// * +// * @param role 角色对象 +// */ +// public int insertRoleMenu(SysRole role) { +// int rows = 1; +// // 新增用户与角色管理 +// List list = new ArrayList(); +// for (Long menuId : role.getMenuIds()) { +// SysRoleMenu rm = new SysRoleMenu(); +// rm.setRoleId(role.getRoleId()); +// rm.setMenuId(menuId); +// list.add(rm); +// } +// if (list.size() > 0) { +// rows = roleMenuMapper.batchRoleMenu(list); +// } +// return rows; +// } +// +// /** +// * 新增角色部门信息(数据权限) +// * +// * @param role 角色对象 +// */ +// public int insertRoleDept(SysRole role) { +// int rows = 1; +// // 新增角色与部门(数据权限)管理 +// List list = new ArrayList(); +// for (Long deptId : role.getDeptIds()) { +// SysRoleDept rd = new SysRoleDept(); +// rd.setRoleId(role.getRoleId()); +// rd.setDeptId(deptId); +// list.add(rd); +// } +// if (list.size() > 0) { +// rows = roleDeptMapper.batchRoleDept(list); +// } +// return rows; +// } +// +// /** +// * 校验角色名称是否唯一 +// * +// * @param role 角色信息 +// * @return 结果 +// */ +// @Override +// public String checkRoleNameUnique(SysRole role) { +// Long roleId = StringUtils.isNull(role.getRoleId()) ? -1L : role.getRoleId(); +// SysRole info = roleMapper.checkRoleNameUnique(role.getRoleName()); +// if (StringUtils.isNotNull(info) && info.getRoleId().longValue() != roleId.longValue()) { +// return UserConstants.ROLE_NAME_NOT_UNIQUE; +// } +// return UserConstants.ROLE_NAME_UNIQUE; +// } +// +// /** +// * 校验角色权限是否唯一 +// * +// * @param role 角色信息 +// * @return 结果 +// */ +// @Override +// public String checkRoleKeyUnique(SysRole role) { +// Long roleId = StringUtils.isNull(role.getRoleId()) ? -1L : role.getRoleId(); +// SysRole info = roleMapper.checkRoleKeyUnique(role.getRoleKey()); +// if (StringUtils.isNotNull(info) && info.getRoleId().longValue() != roleId.longValue()) { +// return UserConstants.ROLE_KEY_NOT_UNIQUE; +// } +// return UserConstants.ROLE_KEY_UNIQUE; +// } +// +// /** +// * 校验角色是否允许操作 +// * +// * @param role 角色信息 +// */ +// @Override +// public void checkRoleAllowed(SysRole role) { +// if (StringUtils.isNotNull(role.getRoleId()) && role.isAdmin()) { +// throw new ServiceException("不允许操作超级管理员角色"); +// } +// } +// +// /** +// * 校验角色是否有数据权限 +// * +// * @param roleId 角色id +// */ +// @Override +// public void checkRoleDataScope(Long roleId) { +// if (!SysUser.isAdmin(ShiroUtils.getUserId())) { +// SysRole role = new SysRole(); +// role.setRoleId(roleId); +// List roles = SpringUtils.getAopProxy(this).selectRoleList(role); +// if (StringUtils.isEmpty(roles)) { +// throw new ServiceException("没有权限访问角色数据!"); +// } +// } +// } +// +// /** +// * 通过角色ID查询角色使用数量 +// * +// * @param roleId 角色ID +// * @return 结果 +// */ +// @Override +// public int countUserRoleByRoleId(Long roleId) { +// return userRoleMapper.countUserRoleByRoleId(roleId); +// } +// +// /** +// * 角色状态修改 +// * +// * @param role 角色信息 +// * @return 结果 +// */ +// @Override +// public int changeStatus(SysRole role) { +// return roleMapper.updateRole(role); +// } +// +// /** +// * 取消授权用户角色 +// * +// * @param userRole 用户和角色关联信息 +// * @return 结果 +// */ +// @Override +// public int deleteAuthUser(SysUserRole userRole) { +// return userRoleMapper.deleteUserRoleInfo(userRole); +// } +// +// /** +// * 批量取消授权用户角色 +// * +// * @param roleId 角色ID +// * @param userIds 需要删除的用户数据ID +// * @return 结果 +// */ +// @Override +// public int deleteAuthUsers(Long roleId, String userIds) { +// return userRoleMapper.deleteUserRoleInfos(roleId, Convert.toLongArray(userIds)); +// } +// +// /** +// * 批量选择授权用户角色 +// * +// * @param roleId 角色ID +// * @param userIds 需要授权的用户数据ID +// * @return 结果 +// */ +// @Override +// public int insertAuthUsers(Long roleId, String userIds) { +// Long[] users = Convert.toLongArray(userIds); +// // 新增用户与角色管理 +// List list = new ArrayList(); +// for (Long userId : users) { +// SysUserRole ur = new SysUserRole(); +// ur.setUserId(userId); +// ur.setRoleId(roleId); +// list.add(ur); +// } +// return userRoleMapper.batchUserRole(list); +// } +} diff --git a/zt-system/src/main/resources/mapper/system/ActiveInfoMapper.xml b/zt-system/src/main/resources/mapper/system/ActiveInfoMapper.xml new file mode 100644 index 000000000..fd12cac72 --- /dev/null +++ b/zt-system/src/main/resources/mapper/system/ActiveInfoMapper.xml @@ -0,0 +1,122 @@ + + + + + + + + + + + + + + + + + + + + + + + + select r.id, r.active_title, r.active_desc,r.active_start_date,r.active_end_date, r.active_pic, r.active_type, r.status, r.del_flag, r.create_time, r.remark + from active_info r + + + + + + + + + + + + + update active_info set del_flag = '2' where id = #{id} + + + + update active_info set del_flag = '2' where id in + + #{id} + + + + + update active_info + + active_title = #{activeTitle}, + active_desc = #{activeDesc}, + active_start_date = #{activeStartDate}, + active_end_date = #{activeEndDate}, + status = #{status}, + active_pic = #{activePic}, + active_type = #{activeType}, + remark = #{remark}, + update_by = #{updateBy}, + update_time = sysdate() + + where id = #{id} + + + + insert into active_info( + active_title, + active_desc, + active_start_date, + active_end_date, + active_type, + active_pic, + status, + remark, + create_by, + create_time + )values( + #{activeTitle}, + #{activeDesc}, + #{activeStartDate}, + #{activeEndDate}, + #{activeType}, + #{activePic}, + #{status}, + #{remark}, + #{createBy}, + sysdate() + ) + + + \ No newline at end of file