若依2.2版本发布
This commit is contained in:
@ -14,20 +14,16 @@ public class BusinessType
|
||||
public static final String INSERT = "1";
|
||||
/** 修改 */
|
||||
public static final String UPDATE = "2";
|
||||
/** 保存 */
|
||||
public static final String SAVE = "3";
|
||||
/** 删除 */
|
||||
public static final String DELETE = "4";
|
||||
public static final String DELETE = "3";
|
||||
/** 授权 */
|
||||
public static final String GRANT = "5";
|
||||
public static final String GRANT = "4";
|
||||
/** 导出 */
|
||||
public static final String EXPORT = "6";
|
||||
public static final String EXPORT = "5";
|
||||
/** 导入 */
|
||||
public static final String IMPORT = "7";
|
||||
public static final String IMPORT = "6";
|
||||
/** 强退 */
|
||||
public static final String FORCE = "8";
|
||||
/** 禁止访问 */
|
||||
public static final String FORBID = "9";
|
||||
public static final String FORCE = "7";
|
||||
/** 生成代码 */
|
||||
public static final String GENCODE = "10";
|
||||
public static final String GENCODE = "8";
|
||||
}
|
||||
|
@ -122,7 +122,7 @@ public class LoginService
|
||||
{
|
||||
user.setLoginIp(ShiroUtils.getIp());
|
||||
user.setLoginDate(DateUtils.getNowDate());
|
||||
userService.updateUser(user);
|
||||
userService.updateUserInfo(user);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -61,6 +61,17 @@ public class BaseController
|
||||
return rspData;
|
||||
}
|
||||
|
||||
/**
|
||||
* 响应返回结果
|
||||
*
|
||||
* @param rows 影响行数
|
||||
* @return 操作结果
|
||||
*/
|
||||
protected AjaxResult toAjax(int rows)
|
||||
{
|
||||
return rows > 0 ? success() : error();
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回成功
|
||||
*/
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.ruoyi.framework.web.service;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.ruoyi.project.system.config.service.IConfigService;
|
||||
|
||||
/**
|
||||
@ -9,7 +9,7 @@ import com.ruoyi.project.system.config.service.IConfigService;
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
@Component
|
||||
@Service("config")
|
||||
public class ConfigService
|
||||
{
|
||||
@Autowired
|
||||
@ -21,7 +21,7 @@ public class ConfigService
|
||||
* @param configName 参数名称
|
||||
* @return 参数键值
|
||||
*/
|
||||
public String selectConfigByKey(String configKey)
|
||||
public String getKey(String configKey)
|
||||
{
|
||||
return configService.selectConfigByKey(configKey);
|
||||
}
|
||||
|
@ -2,7 +2,7 @@ package com.ruoyi.framework.web.service;
|
||||
|
||||
import java.util.List;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.ruoyi.project.system.dict.domain.DictData;
|
||||
import com.ruoyi.project.system.dict.service.IDictDataService;
|
||||
|
||||
@ -11,7 +11,7 @@ import com.ruoyi.project.system.dict.service.IDictDataService;
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
@Component
|
||||
@Service("dict")
|
||||
public class DictService
|
||||
{
|
||||
@Autowired
|
||||
@ -23,8 +23,20 @@ public class DictService
|
||||
* @param dictType 字典类型
|
||||
* @return 参数键值
|
||||
*/
|
||||
public List<DictData> selectDictData(String dictType)
|
||||
public List<DictData> getType(String dictType)
|
||||
{
|
||||
return dictDataService.selectDictDataByType(dictType);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据字典类型和字典键值查询字典数据信息
|
||||
*
|
||||
* @param dictType 字典类型
|
||||
* @param dictValue 字典键值
|
||||
* @return 字典标签
|
||||
*/
|
||||
public String getLabel(String dictType, String dictValue)
|
||||
{
|
||||
return dictDataService.selectDictLabel(dictType, dictValue);
|
||||
}
|
||||
}
|
||||
|
@ -1,14 +1,14 @@
|
||||
package com.ruoyi.framework.shiro.service;
|
||||
package com.ruoyi.framework.web.service;
|
||||
|
||||
import org.apache.shiro.SecurityUtils;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* RuoYi首创 js调用 thymeleaf 实现按钮权限可见性
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
@Component
|
||||
@Service("permission")
|
||||
public class PermissionService
|
||||
{
|
||||
public String hasPermi(String permission)
|
@ -2,12 +2,15 @@ package com.ruoyi.project.common;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URLEncoder;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.util.ResourceUtils;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
@ -20,10 +23,14 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
||||
@Controller
|
||||
public class CommonController
|
||||
{
|
||||
private static final Logger log = LoggerFactory.getLogger(CommonController.class);
|
||||
|
||||
@RequestMapping("common/download")
|
||||
public void fileDownload(String fileName, Boolean delete, HttpServletResponse response, HttpServletRequest request)
|
||||
{
|
||||
String realFileName = System.currentTimeMillis() + fileName.substring(fileName.indexOf("_") + 1);
|
||||
InputStream inputStream = null;
|
||||
OutputStream os = null;
|
||||
try
|
||||
{
|
||||
String filePath = ResourceUtils.getURL("classpath:").getPath() + "static/file/" + fileName;
|
||||
@ -32,16 +39,14 @@ public class CommonController
|
||||
response.setContentType("multipart/form-data");
|
||||
response.setHeader("Content-Disposition", "attachment;fileName=" + setFileDownloadHeader(request, realFileName));
|
||||
File file = new File(filePath);
|
||||
InputStream inputStream = new FileInputStream(file);
|
||||
OutputStream os = response.getOutputStream();
|
||||
inputStream = new FileInputStream(file);
|
||||
os = response.getOutputStream();
|
||||
byte[] b = new byte[1024];
|
||||
int length;
|
||||
while ((length = inputStream.read(b)) > 0)
|
||||
{
|
||||
os.write(b, 0, length);
|
||||
}
|
||||
os.close();
|
||||
inputStream.close();
|
||||
if (delete && file.exists())
|
||||
{
|
||||
file.delete();
|
||||
@ -49,7 +54,19 @@ public class CommonController
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
log.error("下载文件失败", e);
|
||||
}
|
||||
finally
|
||||
{
|
||||
try
|
||||
{
|
||||
os.close();
|
||||
inputStream.close();
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
log.error("close close fail ", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4,7 +4,7 @@ import java.util.List;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.ui.ModelMap;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
@ -94,13 +94,9 @@ public class JobController extends BaseController
|
||||
@ResponseBody
|
||||
public AjaxResult changeStatus(Job job)
|
||||
{
|
||||
if (jobService.changeStatus(job) > 0)
|
||||
{
|
||||
return success();
|
||||
}
|
||||
return error();
|
||||
return toAjax(jobService.changeStatus(job));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 任务调度立即执行一次
|
||||
*/
|
||||
@ -110,50 +106,49 @@ public class JobController extends BaseController
|
||||
@ResponseBody
|
||||
public AjaxResult run(Job job)
|
||||
{
|
||||
if (jobService.run(job) > 0)
|
||||
{
|
||||
return success();
|
||||
}
|
||||
return error();
|
||||
return toAjax(jobService.run(job));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增调度
|
||||
*/
|
||||
@Log(title = "定时任务", action = BusinessType.INSERT)
|
||||
@RequiresPermissions("monitor:job:add")
|
||||
@GetMapping("/add")
|
||||
public String add(Model model)
|
||||
public String add()
|
||||
{
|
||||
return prefix + "/add";
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增保存调度
|
||||
*/
|
||||
@Log(title = "定时任务", action = BusinessType.INSERT)
|
||||
@RequiresPermissions("monitor:job:add")
|
||||
@PostMapping("/add")
|
||||
@ResponseBody
|
||||
public AjaxResult addSave(Job job)
|
||||
{
|
||||
return toAjax(jobService.insertJobCron(job));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改调度
|
||||
*/
|
||||
@Log(title = "定时任务", action = BusinessType.UPDATE)
|
||||
@RequiresPermissions("monitor:job:edit")
|
||||
@GetMapping("/edit/{jobId}")
|
||||
public String edit(@PathVariable("jobId") Long jobId, Model model)
|
||||
public String edit(@PathVariable("jobId") Long jobId, ModelMap mmap)
|
||||
{
|
||||
Job job = jobService.selectJobById(jobId);
|
||||
model.addAttribute("job", job);
|
||||
mmap.put("job", jobService.selectJobById(jobId));
|
||||
return prefix + "/edit";
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存调度
|
||||
* 修改保存调度
|
||||
*/
|
||||
@Log(title = "定时任务", action = BusinessType.SAVE)
|
||||
@RequiresPermissions("monitor:job:save")
|
||||
@PostMapping("/save")
|
||||
@Log(title = "定时任务", action = BusinessType.UPDATE)
|
||||
@RequiresPermissions("monitor:job:edit")
|
||||
@PostMapping("/edit")
|
||||
@ResponseBody
|
||||
public AjaxResult save(Job job)
|
||||
public AjaxResult editSave(Job job)
|
||||
{
|
||||
if (jobService.saveJobCron(job) > 0)
|
||||
{
|
||||
return success();
|
||||
}
|
||||
return error();
|
||||
return toAjax(jobService.updateJobCron(job));
|
||||
}
|
||||
}
|
||||
|
@ -71,15 +71,6 @@ public class JobLogController extends BaseController
|
||||
@ResponseBody
|
||||
public AjaxResult remove(String ids)
|
||||
{
|
||||
try
|
||||
{
|
||||
jobLogService.deleteJobLogByIds(ids);
|
||||
return success();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
return error(e.getMessage());
|
||||
}
|
||||
return toAjax(jobLogService.deleteJobLogByIds(ids));
|
||||
}
|
||||
}
|
||||
|
@ -66,7 +66,7 @@ public interface IJobService
|
||||
* @return 结果
|
||||
*/
|
||||
public int changeStatus(Job job);
|
||||
|
||||
|
||||
/**
|
||||
* 立即运行任务
|
||||
*
|
||||
@ -81,7 +81,7 @@ public interface IJobService
|
||||
* @param job 调度信息
|
||||
* @return 结果
|
||||
*/
|
||||
public int addJobCron(Job job);
|
||||
public int insertJobCron(Job job);
|
||||
|
||||
/**
|
||||
* 更新任务的时间表达式
|
||||
@ -91,11 +91,4 @@ public interface IJobService
|
||||
*/
|
||||
public int updateJobCron(Job job);
|
||||
|
||||
/**
|
||||
* 保存任务的时间表达式
|
||||
*
|
||||
* @param job 调度信息
|
||||
* @return 结果
|
||||
*/
|
||||
public int saveJobCron(Job job);
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ import com.ruoyi.project.monitor.job.mapper.JobLogMapper;
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
@Service("jobLogService")
|
||||
@Service
|
||||
public class JobLogServiceImpl implements IJobLogService
|
||||
{
|
||||
|
||||
|
@ -1,17 +1,13 @@
|
||||
package com.ruoyi.project.monitor.job.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
|
||||
import org.quartz.CronTrigger;
|
||||
import org.quartz.Scheduler;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.ruoyi.common.constant.ScheduleConstants;
|
||||
import com.ruoyi.common.support.Convert;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.common.utils.security.ShiroUtils;
|
||||
import com.ruoyi.project.monitor.job.domain.Job;
|
||||
import com.ruoyi.project.monitor.job.mapper.JobMapper;
|
||||
@ -22,7 +18,7 @@ import com.ruoyi.project.monitor.job.util.ScheduleUtils;
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
@Service("jobService")
|
||||
@Service
|
||||
public class JobServiceImpl implements IJobService
|
||||
{
|
||||
@Autowired
|
||||
@ -166,7 +162,7 @@ public class JobServiceImpl implements IJobService
|
||||
}
|
||||
return rows;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 立即运行任务
|
||||
*
|
||||
@ -184,7 +180,7 @@ public class JobServiceImpl implements IJobService
|
||||
* @param job 调度信息 调度信息
|
||||
*/
|
||||
@Override
|
||||
public int addJobCron(Job job)
|
||||
public int insertJobCron(Job job)
|
||||
{
|
||||
job.setCreateBy(ShiroUtils.getLoginName());
|
||||
job.setStatus(ScheduleConstants.Status.PAUSE.getValue());
|
||||
@ -204,6 +200,7 @@ public class JobServiceImpl implements IJobService
|
||||
@Override
|
||||
public int updateJobCron(Job job)
|
||||
{
|
||||
job.setUpdateBy(ShiroUtils.getLoginName());
|
||||
int rows = jobMapper.updateJob(job);
|
||||
if (rows > 0)
|
||||
{
|
||||
@ -212,25 +209,4 @@ public class JobServiceImpl implements IJobService
|
||||
return rows;
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存任务的时间表达式
|
||||
*
|
||||
* @param job 调度信息
|
||||
*/
|
||||
@Override
|
||||
public int saveJobCron(Job job)
|
||||
{
|
||||
Long jobId = job.getJobId();
|
||||
int rows = 0;
|
||||
if (StringUtils.isNotNull(jobId))
|
||||
{
|
||||
rows = updateJobCron(job);
|
||||
}
|
||||
else
|
||||
{
|
||||
rows = addJobCron(job);
|
||||
}
|
||||
return rows;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -71,11 +71,6 @@ public class LogininforController extends BaseController
|
||||
@ResponseBody
|
||||
public AjaxResult remove(String ids)
|
||||
{
|
||||
int rows = logininforService.deleteLogininforByIds(ids);
|
||||
if (rows > 0)
|
||||
{
|
||||
return success();
|
||||
}
|
||||
return error();
|
||||
return toAjax(logininforService.deleteLogininforByIds(ids));
|
||||
}
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ public class Logininfor extends BaseEntity
|
||||
private static final long serialVersionUID = 1L;
|
||||
/** ID */
|
||||
@Excel(name = "序号")
|
||||
private Integer infoId;
|
||||
private Long infoId;
|
||||
/** 用户账号 */
|
||||
@Excel(name = "用户账号")
|
||||
private String loginName;
|
||||
@ -40,12 +40,12 @@ public class Logininfor extends BaseEntity
|
||||
@Excel(name = "访问时间")
|
||||
private Date loginTime;
|
||||
|
||||
public Integer getInfoId()
|
||||
public Long getInfoId()
|
||||
{
|
||||
return infoId;
|
||||
}
|
||||
|
||||
public void setInfoId(Integer infoId)
|
||||
public void setInfoId(Long infoId)
|
||||
{
|
||||
this.infoId = infoId;
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ import com.ruoyi.project.monitor.logininfor.mapper.LogininforMapper;
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
@Service("logininforService")
|
||||
@Service
|
||||
public class LogininforServiceImpl implements ILogininforService
|
||||
{
|
||||
|
||||
|
@ -15,7 +15,7 @@ import com.ruoyi.project.monitor.online.mapper.UserOnlineMapper;
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
@Service("userOnlineService")
|
||||
@Service
|
||||
public class UserOnlineServiceImpl implements IUserOnlineService
|
||||
{
|
||||
@Autowired
|
||||
|
@ -4,7 +4,7 @@ import java.util.List;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.ui.ModelMap;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
@ -72,20 +72,14 @@ public class OperlogController extends BaseController
|
||||
@ResponseBody
|
||||
public AjaxResult remove(String ids)
|
||||
{
|
||||
int rows = operLogService.deleteOperLogByIds(ids);
|
||||
if (rows > 0)
|
||||
{
|
||||
return success();
|
||||
}
|
||||
return error();
|
||||
return toAjax(operLogService.deleteOperLogByIds(ids));
|
||||
}
|
||||
|
||||
@RequiresPermissions("monitor:operlog:detail")
|
||||
@GetMapping("/detail/{operId}")
|
||||
public String detail(@PathVariable("operId") Long deptId, Model model)
|
||||
public String detail(@PathVariable("operId") Long deptId, ModelMap mmap)
|
||||
{
|
||||
OperLog operLog = operLogService.selectOperLogById(deptId);
|
||||
model.addAttribute("operLog", operLog);
|
||||
mmap.put("operLog", operLogService.selectOperLogById(deptId));
|
||||
return prefix + "/detail";
|
||||
}
|
||||
}
|
||||
|
@ -16,7 +16,7 @@ public class OperLog extends BaseEntity
|
||||
|
||||
/** 日志主键 */
|
||||
@Excel(name = "操作序号")
|
||||
private Integer operId;
|
||||
private Long operId;
|
||||
|
||||
/** 操作模块 */
|
||||
@Excel(name = "操作模块")
|
||||
@ -70,12 +70,12 @@ public class OperLog extends BaseEntity
|
||||
@Excel(name = "操作时间")
|
||||
private Date operTime;
|
||||
|
||||
public Integer getOperId()
|
||||
public Long getOperId()
|
||||
{
|
||||
return operId;
|
||||
}
|
||||
|
||||
public void setOperId(Integer operId)
|
||||
public void setOperId(Long operId)
|
||||
{
|
||||
this.operId = operId;
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ import com.ruoyi.project.monitor.operlog.mapper.OperLogMapper;
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
@Service("operLogService")
|
||||
@Service
|
||||
public class OperLogServiceImpl implements IOperLogService
|
||||
{
|
||||
@Autowired
|
||||
|
@ -4,7 +4,7 @@ import java.util.List;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.ui.ModelMap;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
@ -35,7 +35,7 @@ public class ConfigController extends BaseController
|
||||
|
||||
@RequiresPermissions("system:config:view")
|
||||
@GetMapping()
|
||||
public String index()
|
||||
public String config()
|
||||
{
|
||||
return prefix + "/config";
|
||||
}
|
||||
@ -52,7 +52,6 @@ public class ConfigController extends BaseController
|
||||
List<Config> list = configService.selectConfigList(config);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
|
||||
@Log(title = "参数管理", action = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
@ -74,41 +73,44 @@ public class ConfigController extends BaseController
|
||||
/**
|
||||
* 新增参数配置
|
||||
*/
|
||||
@RequiresPermissions("system:config:add")
|
||||
@Log(title = "参数管理", action = BusinessType.INSERT)
|
||||
@GetMapping("/add")
|
||||
public String add()
|
||||
{
|
||||
return prefix + "/add";
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增保存参数配置
|
||||
*/
|
||||
@RequiresPermissions("system:config:add")
|
||||
@Log(title = "参数管理", action = BusinessType.INSERT)
|
||||
@PostMapping("/add")
|
||||
@ResponseBody
|
||||
public AjaxResult addSave(Config config)
|
||||
{
|
||||
return toAjax(configService.insertConfig(config));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改参数配置
|
||||
*/
|
||||
@RequiresPermissions("system:config:edit")
|
||||
@Log(title = "参数管理", action = BusinessType.UPDATE)
|
||||
@GetMapping("/edit/{configId}")
|
||||
public String edit(@PathVariable("configId") Integer configId, Model model)
|
||||
public String edit(@PathVariable("configId") Long configId, ModelMap mmap)
|
||||
{
|
||||
Config config = configService.selectConfigById(configId);
|
||||
model.addAttribute("config", config);
|
||||
mmap.addAttribute("config", configService.selectConfigById(configId));
|
||||
return prefix + "/edit";
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存参数配置
|
||||
* 修改保存参数配置
|
||||
*/
|
||||
@RequiresPermissions("system:config:save")
|
||||
@Log(title = "参数管理", action = BusinessType.SAVE)
|
||||
@PostMapping("/save")
|
||||
@RequiresPermissions("system:config:edit")
|
||||
@Log(title = "参数管理", action = BusinessType.UPDATE)
|
||||
@PostMapping("/edit")
|
||||
@ResponseBody
|
||||
public AjaxResult save(Config config)
|
||||
public AjaxResult editSave(Config config)
|
||||
{
|
||||
if (configService.saveConfig(config) > 0)
|
||||
{
|
||||
return success();
|
||||
}
|
||||
return error();
|
||||
return toAjax(configService.updateConfig(config));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -120,11 +122,7 @@ public class ConfigController extends BaseController
|
||||
@ResponseBody
|
||||
public AjaxResult remove(String ids)
|
||||
{
|
||||
if (configService.deleteConfigByIds(ids) > 0)
|
||||
{
|
||||
return success();
|
||||
}
|
||||
return error();
|
||||
return toAjax(configService.deleteConfigByIds(ids));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -14,7 +14,7 @@ public class Config extends BaseEntity
|
||||
|
||||
/** 参数主键 */
|
||||
@Excel(name = "参数主键")
|
||||
private Integer configId;
|
||||
private Long configId;
|
||||
|
||||
/** 参数名称 */
|
||||
@Excel(name = "参数名称")
|
||||
@ -32,12 +32,12 @@ public class Config extends BaseEntity
|
||||
@Excel(name = "系统内置")
|
||||
private String configType;
|
||||
|
||||
public Integer getConfigId()
|
||||
public Long getConfigId()
|
||||
{
|
||||
return configId;
|
||||
}
|
||||
|
||||
public void setConfigId(Integer configId)
|
||||
public void setConfigId(Long configId)
|
||||
{
|
||||
this.configId = configId;
|
||||
}
|
||||
|
@ -10,22 +10,13 @@ import java.util.List;
|
||||
*/
|
||||
public interface ConfigMapper
|
||||
{
|
||||
|
||||
/**
|
||||
* 查询参数配置信息
|
||||
*
|
||||
* @param configId 参数配置ID
|
||||
* @param configId 参数配置信息
|
||||
* @return 参数配置信息
|
||||
*/
|
||||
public Config selectConfigById(Integer configId);
|
||||
|
||||
/**
|
||||
* 根据键名查询参数配置信息
|
||||
*
|
||||
* @param configKey 参数键名
|
||||
* @return 参数配置信息
|
||||
*/
|
||||
public Config selectConfigByKey(String configKey);
|
||||
public Config selectConfig(Config config);
|
||||
|
||||
/**
|
||||
* 查询参数配置列表
|
||||
@ -35,6 +26,14 @@ public interface ConfigMapper
|
||||
*/
|
||||
public List<Config> selectConfigList(Config config);
|
||||
|
||||
/**
|
||||
* 根据键名查询参数配置信息
|
||||
*
|
||||
* @param configKey 参数键名
|
||||
* @return 参数配置信息
|
||||
*/
|
||||
public Config checkConfigKeyUnique(String configKey);
|
||||
|
||||
/**
|
||||
* 新增参数配置
|
||||
*
|
||||
@ -51,14 +50,6 @@ public interface ConfigMapper
|
||||
*/
|
||||
public int updateConfig(Config config);
|
||||
|
||||
/**
|
||||
* 删除参数配置
|
||||
*
|
||||
* @param configId 参数配置ID
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteConfigById(Integer configId);
|
||||
|
||||
/**
|
||||
* 批量删除参数配置
|
||||
*
|
||||
|
@ -6,6 +6,7 @@ import org.springframework.stereotype.Service;
|
||||
import com.ruoyi.common.constant.UserConstants;
|
||||
import com.ruoyi.common.support.Convert;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.common.utils.security.ShiroUtils;
|
||||
import com.ruoyi.project.system.config.domain.Config;
|
||||
import com.ruoyi.project.system.config.mapper.ConfigMapper;
|
||||
|
||||
@ -27,9 +28,11 @@ public class ConfigServiceImpl implements IConfigService
|
||||
* @return 参数配置信息
|
||||
*/
|
||||
@Override
|
||||
public Config selectConfigById(Integer configId)
|
||||
public Config selectConfigById(Long configId)
|
||||
{
|
||||
return configMapper.selectConfigById(configId);
|
||||
Config config = new Config();
|
||||
config.setConfigId(configId);
|
||||
return configMapper.selectConfig(config);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -41,8 +44,10 @@ public class ConfigServiceImpl implements IConfigService
|
||||
@Override
|
||||
public String selectConfigByKey(String configKey)
|
||||
{
|
||||
Config config = configMapper.selectConfigByKey(configKey);
|
||||
return StringUtils.isNotNull(config) ? config.getConfigValue() : "";
|
||||
Config config = new Config();
|
||||
config.setConfigKey(configKey);
|
||||
Config retConfig = configMapper.selectConfig(config);
|
||||
return StringUtils.isNotNull(retConfig) ? retConfig.getConfigValue() : "";
|
||||
}
|
||||
|
||||
/**
|
||||
@ -66,6 +71,7 @@ public class ConfigServiceImpl implements IConfigService
|
||||
@Override
|
||||
public int insertConfig(Config config)
|
||||
{
|
||||
config.setCreateBy(ShiroUtils.getLoginName());
|
||||
return configMapper.insertConfig(config);
|
||||
}
|
||||
|
||||
@ -78,43 +84,10 @@ public class ConfigServiceImpl implements IConfigService
|
||||
@Override
|
||||
public int updateConfig(Config config)
|
||||
{
|
||||
config.setUpdateBy(ShiroUtils.getLoginName());
|
||||
return configMapper.updateConfig(config);
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存参数配置
|
||||
*
|
||||
* @param config 参数配置信息
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int saveConfig(Config config)
|
||||
{
|
||||
Integer configId = config.getConfigId();
|
||||
int rows = 0;
|
||||
if (StringUtils.isNotNull(configId))
|
||||
{
|
||||
rows = configMapper.updateConfig(config);
|
||||
}
|
||||
else
|
||||
{
|
||||
rows = configMapper.insertConfig(config);
|
||||
}
|
||||
return rows;
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除参数配置信息
|
||||
*
|
||||
* @param configId 参数配置ID
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteConfigById(Integer configId)
|
||||
{
|
||||
return configMapper.deleteConfigById(configId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除参数配置对象
|
||||
*
|
||||
@ -136,14 +109,9 @@ public class ConfigServiceImpl implements IConfigService
|
||||
@Override
|
||||
public String checkConfigKeyUnique(Config config)
|
||||
{
|
||||
if (config.getConfigId() == null)
|
||||
{
|
||||
config.setConfigId(-1);
|
||||
}
|
||||
Integer configId = config.getConfigId();
|
||||
Config info = configMapper.selectConfigByKey(config.getConfigKey());
|
||||
if (StringUtils.isNotNull(info) && StringUtils.isNotNull(info.getConfigId())
|
||||
&& info.getConfigId().intValue() != configId.intValue())
|
||||
Long configId = StringUtils.isNull(config.getConfigId()) ? -1L : config.getConfigId();
|
||||
Config info = configMapper.checkConfigKeyUnique(config.getConfigKey());
|
||||
if (StringUtils.isNotNull(info) && info.getConfigId().longValue() != configId.longValue())
|
||||
{
|
||||
return UserConstants.CONFIG_KEY_NOT_UNIQUE;
|
||||
}
|
||||
|
@ -17,7 +17,7 @@ public interface IConfigService
|
||||
* @param configId 参数配置ID
|
||||
* @return 参数配置信息
|
||||
*/
|
||||
public Config selectConfigById(Integer configId);
|
||||
public Config selectConfigById(Long configId);
|
||||
|
||||
/**
|
||||
* 根据键名查询参数配置信息
|
||||
@ -51,22 +51,6 @@ public interface IConfigService
|
||||
*/
|
||||
public int updateConfig(Config config);
|
||||
|
||||
/**
|
||||
* 保存参数配置
|
||||
*
|
||||
* @param config 参数配置信息
|
||||
* @return 结果
|
||||
*/
|
||||
public int saveConfig(Config config);
|
||||
|
||||
/**
|
||||
* 删除参数配置信息
|
||||
*
|
||||
* @param configId 参数配置ID
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteConfigById(Integer configId);
|
||||
|
||||
/**
|
||||
* 批量删除参数配置信息
|
||||
*
|
||||
|
@ -5,7 +5,7 @@ import java.util.Map;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.ui.ModelMap;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
@ -49,45 +49,47 @@ public class DeptController extends BaseController
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改
|
||||
* 新增部门
|
||||
*/
|
||||
@Log(title = "部门管理", action = BusinessType.UPDATE)
|
||||
@RequiresPermissions("system:dept:edit")
|
||||
@GetMapping("/edit/{deptId}")
|
||||
public String edit(@PathVariable("deptId") Long deptId, Model model)
|
||||
@GetMapping("/add/{parentId}")
|
||||
public String add(@PathVariable("parentId") Long parentId, ModelMap mmap)
|
||||
{
|
||||
Dept dept = deptService.selectDeptById(deptId);
|
||||
model.addAttribute("dept", dept);
|
||||
return prefix + "/edit";
|
||||
mmap.put("dept", deptService.selectDeptById(parentId));
|
||||
return prefix + "/add";
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增
|
||||
* 新增保存部门
|
||||
*/
|
||||
@Log(title = "部门管理", action = BusinessType.INSERT)
|
||||
@RequiresPermissions("system:dept:add")
|
||||
@GetMapping("/add/{parentId}")
|
||||
public String add(@PathVariable("parentId") Long parentId, Model model)
|
||||
@PostMapping("/add")
|
||||
@ResponseBody
|
||||
public AjaxResult addSave(Dept dept)
|
||||
{
|
||||
Dept dept = deptService.selectDeptById(parentId);
|
||||
model.addAttribute("dept", dept);
|
||||
return prefix + "/add";
|
||||
return toAjax(deptService.insertDept(dept));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改
|
||||
*/
|
||||
@GetMapping("/edit/{deptId}")
|
||||
public String edit(@PathVariable("deptId") Long deptId, ModelMap mmap)
|
||||
{
|
||||
mmap.put("dept", deptService.selectDeptById(deptId));
|
||||
return prefix + "/edit";
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存
|
||||
*/
|
||||
@Log(title = "部门管理", action = BusinessType.SAVE)
|
||||
@RequiresPermissions("system:dept:save")
|
||||
@PostMapping("/save")
|
||||
@Log(title = "部门管理", action = BusinessType.UPDATE)
|
||||
@RequiresPermissions("system:dept:edit")
|
||||
@PostMapping("/edit")
|
||||
@ResponseBody
|
||||
public AjaxResult save(Dept dept)
|
||||
public AjaxResult editSave(Dept dept)
|
||||
{
|
||||
if (deptService.saveDept(dept) > 0)
|
||||
{
|
||||
return success();
|
||||
}
|
||||
return error();
|
||||
return toAjax(deptService.updateDept(dept));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -107,11 +109,7 @@ public class DeptController extends BaseController
|
||||
{
|
||||
return error(1, "部门存在用户,不允许删除");
|
||||
}
|
||||
if (deptService.deleteDeptById(deptId) > 0)
|
||||
{
|
||||
return success();
|
||||
}
|
||||
return error();
|
||||
return toAjax(deptService.deleteDeptById(deptId));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -133,9 +131,9 @@ public class DeptController extends BaseController
|
||||
* 选择部门树
|
||||
*/
|
||||
@GetMapping("/selectDeptTree/{deptId}")
|
||||
public String selectDeptTree(@PathVariable("deptId") Long deptId, Model model)
|
||||
public String selectDeptTree(@PathVariable("deptId") Long deptId, ModelMap mmap)
|
||||
{
|
||||
model.addAttribute("treeName", deptService.selectDeptById(deptId).getDeptName());
|
||||
mmap.put("treeName", deptService.selectDeptById(deptId).getDeptName());
|
||||
return prefix + "/tree";
|
||||
}
|
||||
|
||||
|
@ -5,7 +5,7 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.ruoyi.common.constant.UserConstants;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.common.utils.security.ShiroUtils;
|
||||
@ -17,7 +17,7 @@ import com.ruoyi.project.system.dept.mapper.DeptMapper;
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
@Repository("deptService")
|
||||
@Service
|
||||
public class DeptServiceImpl implements IDeptService
|
||||
{
|
||||
@Autowired
|
||||
@ -111,24 +111,29 @@ public class DeptServiceImpl implements IDeptService
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存部门信息
|
||||
* 新增保存部门信息
|
||||
*
|
||||
* @param dept 部门信息
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int saveDept(Dept dept)
|
||||
public int insertDept(Dept dept)
|
||||
{
|
||||
if (StringUtils.isNotNull(dept.getDeptId()))
|
||||
{
|
||||
dept.setUpdateBy(ShiroUtils.getLoginName());
|
||||
return deptMapper.updateDept(dept);
|
||||
}
|
||||
else
|
||||
{
|
||||
dept.setCreateBy(ShiroUtils.getLoginName());
|
||||
return deptMapper.insertDept(dept);
|
||||
}
|
||||
dept.setCreateBy(ShiroUtils.getLoginName());
|
||||
return deptMapper.insertDept(dept);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改保存部门信息
|
||||
*
|
||||
* @param dept 部门信息
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int updateDept(Dept dept)
|
||||
{
|
||||
dept.setUpdateBy(ShiroUtils.getLoginName());
|
||||
return deptMapper.updateDept(dept);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -152,14 +157,9 @@ public class DeptServiceImpl implements IDeptService
|
||||
@Override
|
||||
public String checkDeptNameUnique(Dept dept)
|
||||
{
|
||||
if (dept.getDeptId() == null)
|
||||
{
|
||||
dept.setDeptId(-1L);
|
||||
}
|
||||
Long deptId = dept.getDeptId();
|
||||
Long deptId = StringUtils.isNull(dept.getDeptId()) ? -1L : dept.getDeptId();
|
||||
Dept info = deptMapper.checkDeptNameUnique(dept.getDeptName());
|
||||
if (StringUtils.isNotNull(info) && StringUtils.isNotNull(info.getDeptId())
|
||||
&& info.getDeptId().longValue() != deptId.longValue())
|
||||
if (StringUtils.isNotNull(info) && info.getDeptId().longValue() != deptId.longValue())
|
||||
{
|
||||
return UserConstants.DEPT_NAME_NOT_UNIQUE;
|
||||
}
|
||||
|
@ -58,12 +58,20 @@ public interface IDeptService
|
||||
public int deleteDeptById(Long deptId);
|
||||
|
||||
/**
|
||||
* 保存部门信息
|
||||
* 新增保存部门信息
|
||||
*
|
||||
* @param dept 部门信息
|
||||
* @return 结果
|
||||
*/
|
||||
public int saveDept(Dept dept);
|
||||
public int insertDept(Dept dept);
|
||||
|
||||
/**
|
||||
* 修改保存部门信息
|
||||
*
|
||||
* @param dept 部门信息
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateDept(Dept dept);
|
||||
|
||||
/**
|
||||
* 根据部门ID查询信息
|
||||
|
@ -4,7 +4,7 @@ import java.util.List;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.ui.ModelMap;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
@ -67,45 +67,48 @@ public class DictDataController extends BaseController
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改字典类型
|
||||
*/
|
||||
@Log(title = "字典数据", action = BusinessType.UPDATE)
|
||||
@RequiresPermissions("system:dict:edit")
|
||||
@GetMapping("/edit/{dictCode}")
|
||||
public String edit(@PathVariable("dictCode") Long dictCode, Model model)
|
||||
{
|
||||
DictData dict = dictDataService.selectDictDataById(dictCode);
|
||||
model.addAttribute("dict", dict);
|
||||
return prefix + "/edit";
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增字典类型
|
||||
*/
|
||||
@Log(title = "字典数据", action = BusinessType.INSERT)
|
||||
@RequiresPermissions("system:dict:add")
|
||||
@GetMapping("/add/{dictType}")
|
||||
public String add(@PathVariable("dictType") String dictType, Model model)
|
||||
public String add(@PathVariable("dictType") String dictType, ModelMap mmap)
|
||||
{
|
||||
model.addAttribute("dictType", dictType);
|
||||
mmap.put("dictType", dictType);
|
||||
return prefix + "/add";
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存字典类型
|
||||
* 新增保存字典类型
|
||||
*/
|
||||
@Log(title = "字典数据", action = BusinessType.SAVE)
|
||||
@RequiresPermissions("system:dict:save")
|
||||
@PostMapping("/save")
|
||||
@Log(title = "字典数据", action = BusinessType.INSERT)
|
||||
@RequiresPermissions("system:dict:add")
|
||||
@PostMapping("/add")
|
||||
@ResponseBody
|
||||
public AjaxResult save(DictData dict)
|
||||
public AjaxResult addSave(DictData dict)
|
||||
{
|
||||
if (dictDataService.saveDictData(dict) > 0)
|
||||
{
|
||||
return success();
|
||||
}
|
||||
return error();
|
||||
return toAjax(dictDataService.insertDictData(dict));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改字典类型
|
||||
*/
|
||||
@GetMapping("/edit/{dictCode}")
|
||||
public String edit(@PathVariable("dictCode") Long dictCode, ModelMap mmap)
|
||||
{
|
||||
mmap.put("dict", dictDataService.selectDictDataById(dictCode));
|
||||
return prefix + "/edit";
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改保存字典类型
|
||||
*/
|
||||
@Log(title = "字典数据", action = BusinessType.UPDATE)
|
||||
@RequiresPermissions("system:dict:edit")
|
||||
@PostMapping("/edit")
|
||||
@ResponseBody
|
||||
public AjaxResult editSave(DictData dict)
|
||||
{
|
||||
return toAjax(dictDataService.updateDictData(dict));
|
||||
}
|
||||
|
||||
@Log(title = "字典数据", action = BusinessType.DELETE)
|
||||
@ -114,11 +117,6 @@ public class DictDataController extends BaseController
|
||||
@ResponseBody
|
||||
public AjaxResult remove(String ids)
|
||||
{
|
||||
int rows = dictDataService.deleteDictDataByIds(ids);
|
||||
if (rows > 0)
|
||||
{
|
||||
return success();
|
||||
}
|
||||
return error();
|
||||
return toAjax(dictDataService.deleteDictDataByIds(ids));
|
||||
}
|
||||
}
|
||||
|
@ -4,7 +4,7 @@ import java.util.List;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.ui.ModelMap;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
@ -67,24 +67,9 @@ public class DictTypeController extends BaseController
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改字典类型
|
||||
*/
|
||||
@Log(title = "字典类型", action = BusinessType.UPDATE)
|
||||
@RequiresPermissions("system:dict:edit")
|
||||
@GetMapping("/edit/{dictId}")
|
||||
public String edit(@PathVariable("dictId") Long dictId, Model model)
|
||||
{
|
||||
DictType dict = dictTypeService.selectDictTypeById(dictId);
|
||||
model.addAttribute("dict", dict);
|
||||
return prefix + "/edit";
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增字典类型
|
||||
*/
|
||||
@Log(title = "字典类型", action = BusinessType.INSERT)
|
||||
@RequiresPermissions("system:dict:add")
|
||||
@GetMapping("/add")
|
||||
public String add()
|
||||
{
|
||||
@ -92,19 +77,37 @@ public class DictTypeController extends BaseController
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存字典类型
|
||||
* 新增保存字典类型
|
||||
*/
|
||||
@Log(title = "字典类型", action = BusinessType.SAVE)
|
||||
@RequiresPermissions("system:dict:save")
|
||||
@PostMapping("/save")
|
||||
@Log(title = "字典类型", action = BusinessType.INSERT)
|
||||
@RequiresPermissions("system:dict:add")
|
||||
@PostMapping("/add")
|
||||
@ResponseBody
|
||||
public AjaxResult save(DictType dict)
|
||||
public AjaxResult addSave(DictType dict)
|
||||
{
|
||||
if (dictTypeService.saveDictType(dict) > 0)
|
||||
{
|
||||
return success();
|
||||
}
|
||||
return error();
|
||||
return toAjax(dictTypeService.insertDictType(dict));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改字典类型
|
||||
*/
|
||||
@GetMapping("/edit/{dictId}")
|
||||
public String edit(@PathVariable("dictId") Long dictId, ModelMap mmap)
|
||||
{
|
||||
mmap.put("dict", dictTypeService.selectDictTypeById(dictId));
|
||||
return prefix + "/edit";
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改保存字典类型
|
||||
*/
|
||||
@Log(title = "字典类型", action = BusinessType.UPDATE)
|
||||
@RequiresPermissions("system:dict:edit")
|
||||
@PostMapping("/edit")
|
||||
@ResponseBody
|
||||
public AjaxResult editSave(DictType dict)
|
||||
{
|
||||
return toAjax(dictTypeService.updateDictType(dict));
|
||||
}
|
||||
|
||||
@Log(title = "字典类型", action = BusinessType.DELETE)
|
||||
@ -115,8 +118,7 @@ public class DictTypeController extends BaseController
|
||||
{
|
||||
try
|
||||
{
|
||||
dictTypeService.deleteDictTypeByIds(ids);
|
||||
return success();
|
||||
return toAjax(dictTypeService.deleteDictTypeByIds(ids));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@ -129,12 +131,10 @@ public class DictTypeController extends BaseController
|
||||
*/
|
||||
@RequiresPermissions("system:dict:list")
|
||||
@GetMapping("/detail/{dictId}")
|
||||
public String detail(@PathVariable("dictId") Long dictId, Model model)
|
||||
public String detail(@PathVariable("dictId") Long dictId, ModelMap mmap)
|
||||
{
|
||||
DictType dict = dictTypeService.selectDictTypeById(dictId);
|
||||
List<DictType> dictTypeList = dictTypeService.selectDictTypeAll();
|
||||
model.addAttribute("dict", dict);
|
||||
model.addAttribute("dictList", dictTypeList);
|
||||
mmap.put("dict", dictTypeService.selectDictTypeById(dictId));
|
||||
mmap.put("dictList", dictTypeService.selectDictTypeAll());
|
||||
return "system/dict/data/data";
|
||||
}
|
||||
|
||||
|
@ -36,6 +36,9 @@ public class DictData extends BaseEntity
|
||||
@Excel(name = "字典样式")
|
||||
private String cssClass;
|
||||
|
||||
/** 表格字典样式 */
|
||||
private String listClass;
|
||||
|
||||
/** 是否默认(Y是 N否) */
|
||||
@Excel(name = "是否默认")
|
||||
private String isDefault;
|
||||
@ -104,6 +107,16 @@ public class DictData extends BaseEntity
|
||||
this.cssClass = cssClass;
|
||||
}
|
||||
|
||||
public String getListClass()
|
||||
{
|
||||
return listClass;
|
||||
}
|
||||
|
||||
public void setListClass(String listClass)
|
||||
{
|
||||
this.listClass = listClass;
|
||||
}
|
||||
|
||||
public String getIsDefault()
|
||||
{
|
||||
return isDefault;
|
||||
|
@ -1,6 +1,9 @@
|
||||
package com.ruoyi.project.system.dict.mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import com.ruoyi.project.system.dict.domain.DictData;
|
||||
|
||||
/**
|
||||
@ -18,7 +21,7 @@ public interface DictDataMapper
|
||||
* @return 字典数据集合信息
|
||||
*/
|
||||
public List<DictData> selectDictDataList(DictData dictData);
|
||||
|
||||
|
||||
/**
|
||||
* 根据字典类型查询字典数据
|
||||
*
|
||||
@ -27,6 +30,15 @@ public interface DictDataMapper
|
||||
*/
|
||||
public List<DictData> selectDictDataByType(String dictType);
|
||||
|
||||
/**
|
||||
* 根据字典类型和字典键值查询字典数据信息
|
||||
*
|
||||
* @param dictType 字典类型
|
||||
* @param dictValue 字典键值
|
||||
* @return 字典标签
|
||||
*/
|
||||
public String selectDictLabel(@Param("dictType") String dictType, @Param("dictValue") String dictValue);
|
||||
|
||||
/**
|
||||
* 根据字典数据ID查询信息
|
||||
*
|
||||
@ -34,7 +46,7 @@ public interface DictDataMapper
|
||||
* @return 字典数据
|
||||
*/
|
||||
public DictData selectDictDataById(Long dictCode);
|
||||
|
||||
|
||||
/**
|
||||
* 查询字典数据
|
||||
*
|
||||
@ -42,7 +54,7 @@ public interface DictDataMapper
|
||||
* @return 字典数据
|
||||
*/
|
||||
public int countDictDataByType(String dictType);
|
||||
|
||||
|
||||
/**
|
||||
* 通过字典ID删除字典数据信息
|
||||
*
|
||||
@ -50,7 +62,7 @@ public interface DictDataMapper
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteDictDataById(Long dictCode);
|
||||
|
||||
|
||||
/**
|
||||
* 批量删除字典数据
|
||||
*
|
||||
|
@ -4,7 +4,6 @@ import java.util.List;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.ruoyi.common.support.Convert;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.common.utils.security.ShiroUtils;
|
||||
import com.ruoyi.project.system.dict.domain.DictData;
|
||||
import com.ruoyi.project.system.dict.mapper.DictDataMapper;
|
||||
@ -14,7 +13,7 @@ import com.ruoyi.project.system.dict.mapper.DictDataMapper;
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
@Service("dictDataService")
|
||||
@Service
|
||||
public class DictDataServiceImpl implements IDictDataService
|
||||
{
|
||||
@Autowired
|
||||
@ -44,6 +43,18 @@ public class DictDataServiceImpl implements IDictDataService
|
||||
return dictDataMapper.selectDictDataByType(dictType);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据字典类型和字典键值查询字典数据信息
|
||||
*
|
||||
* @param dictType 字典类型
|
||||
* @param dictValue 字典键值
|
||||
* @return 字典标签
|
||||
*/
|
||||
public String selectDictLabel(String dictType, String dictValue)
|
||||
{
|
||||
return dictDataMapper.selectDictLabel(dictType, dictValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据字典数据ID查询信息
|
||||
*
|
||||
@ -81,25 +92,29 @@ public class DictDataServiceImpl implements IDictDataService
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存字典数据信息
|
||||
* 新增保存字典数据信息
|
||||
*
|
||||
* @param dictData 字典数据信息
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int saveDictData(DictData dictData)
|
||||
public int insertDictData(DictData dictData)
|
||||
{
|
||||
Long dictCode = dictData.getDictCode();
|
||||
if (StringUtils.isNotNull(dictCode))
|
||||
{
|
||||
dictData.setUpdateBy(ShiroUtils.getLoginName());
|
||||
return dictDataMapper.updateDictData(dictData);
|
||||
}
|
||||
else
|
||||
{
|
||||
dictData.setCreateBy(ShiroUtils.getLoginName());
|
||||
return dictDataMapper.insertDictData(dictData);
|
||||
}
|
||||
dictData.setCreateBy(ShiroUtils.getLoginName());
|
||||
return dictDataMapper.insertDictData(dictData);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改保存字典数据信息
|
||||
*
|
||||
* @param dictData 字典数据信息
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int updateDictData(DictData dictData)
|
||||
{
|
||||
dictData.setUpdateBy(ShiroUtils.getLoginName());
|
||||
return dictDataMapper.updateDictData(dictData);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -16,7 +16,7 @@ import com.ruoyi.project.system.dict.mapper.DictTypeMapper;
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
@Service("dictTypeService")
|
||||
@Service
|
||||
public class DictTypeServiceImpl implements IDictTypeService
|
||||
{
|
||||
@Autowired
|
||||
@ -95,25 +95,29 @@ public class DictTypeServiceImpl implements IDictTypeService
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存字典类型信息
|
||||
* 新增保存字典类型信息
|
||||
*
|
||||
* @param dictType 字典类型信息
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int saveDictType(DictType dictType)
|
||||
public int insertDictType(DictType dictType)
|
||||
{
|
||||
Long dictId = dictType.getDictId();
|
||||
if (StringUtils.isNotNull(dictId))
|
||||
{
|
||||
dictType.setUpdateBy(ShiroUtils.getLoginName());
|
||||
return dictTypeMapper.updateDictType(dictType);
|
||||
}
|
||||
else
|
||||
{
|
||||
dictType.setCreateBy(ShiroUtils.getLoginName());
|
||||
return dictTypeMapper.insertDictType(dictType);
|
||||
}
|
||||
dictType.setCreateBy(ShiroUtils.getLoginName());
|
||||
return dictTypeMapper.insertDictType(dictType);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改保存字典类型信息
|
||||
*
|
||||
* @param dictType 字典类型信息
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int updateDictType(DictType dictType)
|
||||
{
|
||||
dictType.setUpdateBy(ShiroUtils.getLoginName());
|
||||
return dictTypeMapper.updateDictType(dictType);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -125,11 +129,7 @@ public class DictTypeServiceImpl implements IDictTypeService
|
||||
@Override
|
||||
public String checkDictTypeUnique(DictType dict)
|
||||
{
|
||||
if (dict.getDictId() == null)
|
||||
{
|
||||
dict.setDictId(-1L);
|
||||
}
|
||||
Long dictId = dict.getDictId();
|
||||
Long dictId = StringUtils.isNull(dict.getDictId()) ? -1L : dict.getDictId();
|
||||
DictType dictType = dictTypeMapper.checkDictTypeUnique(dict.getDictType());
|
||||
if (StringUtils.isNotNull(dictType) && dictType.getDictId() != dictId)
|
||||
{
|
||||
|
@ -18,7 +18,7 @@ public interface IDictDataService
|
||||
* @return 字典数据集合信息
|
||||
*/
|
||||
public List<DictData> selectDictDataList(DictData dictData);
|
||||
|
||||
|
||||
/**
|
||||
* 根据字典类型查询字典数据
|
||||
*
|
||||
@ -26,7 +26,16 @@ public interface IDictDataService
|
||||
* @return 字典数据集合信息
|
||||
*/
|
||||
public List<DictData> selectDictDataByType(String dictType);
|
||||
|
||||
|
||||
/**
|
||||
* 根据字典类型和字典键值查询字典数据信息
|
||||
*
|
||||
* @param dictType 字典类型
|
||||
* @param dictValue 字典键值
|
||||
* @return 字典标签
|
||||
*/
|
||||
public String selectDictLabel(String dictType, String dictValue);
|
||||
|
||||
/**
|
||||
* 根据字典数据ID查询信息
|
||||
*
|
||||
@ -34,7 +43,7 @@ public interface IDictDataService
|
||||
* @return 字典数据
|
||||
*/
|
||||
public DictData selectDictDataById(Long dictCode);
|
||||
|
||||
|
||||
/**
|
||||
* 通过字典ID删除字典数据信息
|
||||
*
|
||||
@ -52,11 +61,19 @@ public interface IDictDataService
|
||||
public int deleteDictDataByIds(String ids);
|
||||
|
||||
/**
|
||||
* 保存字典数据信息
|
||||
* 新增保存字典数据信息
|
||||
*
|
||||
* @param dictData 字典数据信息
|
||||
* @return 结果
|
||||
*/
|
||||
public int saveDictData(DictData dictData);
|
||||
public int insertDictData(DictData dictData);
|
||||
|
||||
/**
|
||||
* 修改保存字典数据信息
|
||||
*
|
||||
* @param dictData 字典数据信息
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateDictData(DictData dictData);
|
||||
|
||||
}
|
||||
|
@ -17,7 +17,7 @@ public interface IDictTypeService
|
||||
* @return 字典类型集合信息
|
||||
*/
|
||||
public List<DictType> selectDictTypeList(DictType dictType);
|
||||
|
||||
|
||||
/**
|
||||
* 根据所有字典类型
|
||||
*
|
||||
@ -32,7 +32,7 @@ public interface IDictTypeService
|
||||
* @return 字典类型
|
||||
*/
|
||||
public DictType selectDictTypeById(Long dictId);
|
||||
|
||||
|
||||
/**
|
||||
* 通过字典ID删除字典信息
|
||||
*
|
||||
@ -41,22 +41,29 @@ public interface IDictTypeService
|
||||
*/
|
||||
public int deleteDictTypeById(Long dictId);
|
||||
|
||||
|
||||
/**
|
||||
* 批量删除字典类型
|
||||
*
|
||||
* @param ids 需要删除的数据
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteDictTypeByIds(String ids) throws Exception;
|
||||
public int deleteDictTypeByIds(String ids) throws Exception;
|
||||
|
||||
/**
|
||||
* 保存字典类型信息
|
||||
* 新增保存字典类型信息
|
||||
*
|
||||
* @param dictType 字典类型信息
|
||||
* @return 结果
|
||||
*/
|
||||
public int saveDictType(DictType dictType);
|
||||
public int insertDictType(DictType dictType);
|
||||
|
||||
/**
|
||||
* 修改保存字典类型信息
|
||||
*
|
||||
* @param dictType 字典类型信息
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateDictType(DictType dictType);
|
||||
|
||||
/**
|
||||
* 校验字典类型称是否唯一
|
||||
|
@ -5,7 +5,7 @@ import java.util.Map;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.ui.ModelMap;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
@ -67,33 +67,14 @@ public class MenuController extends BaseController
|
||||
{
|
||||
return error(1, "菜单已分配,不允许删除");
|
||||
}
|
||||
if (menuService.deleteMenuById(menuId) > 0)
|
||||
{
|
||||
return success();
|
||||
}
|
||||
return error();
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改菜单
|
||||
*/
|
||||
@Log(title = "菜单管理", action = BusinessType.UPDATE)
|
||||
@RequiresPermissions("system:menu:edit")
|
||||
@GetMapping("/edit/{menuId}")
|
||||
public String edit(@PathVariable("menuId") Long menuId, Model model)
|
||||
{
|
||||
Menu menu = menuService.selectMenuById(menuId);
|
||||
model.addAttribute("menu", menu);
|
||||
return prefix + "/edit";
|
||||
return toAjax(menuService.deleteMenuById(menuId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增
|
||||
*/
|
||||
@Log(title = "菜单管理", action = BusinessType.INSERT)
|
||||
@RequiresPermissions("system:menu:add")
|
||||
@GetMapping("/add/{parentId}")
|
||||
public String add(@PathVariable("parentId") Long parentId, Model model)
|
||||
public String add(@PathVariable("parentId") Long parentId, ModelMap mmap)
|
||||
{
|
||||
Menu menu = null;
|
||||
if (0L != parentId)
|
||||
@ -106,24 +87,42 @@ public class MenuController extends BaseController
|
||||
menu.setMenuId(0L);
|
||||
menu.setMenuName("主目录");
|
||||
}
|
||||
model.addAttribute("menu", menu);
|
||||
mmap.put("menu", menu);
|
||||
return prefix + "/add";
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存菜单
|
||||
* 新增保存菜单
|
||||
*/
|
||||
@Log(title = "菜单管理", action = BusinessType.SAVE)
|
||||
@RequiresPermissions("system:menu:save")
|
||||
@PostMapping("/save")
|
||||
@Log(title = "菜单管理", action = BusinessType.INSERT)
|
||||
@RequiresPermissions("system:menu:add")
|
||||
@PostMapping("/add")
|
||||
@ResponseBody
|
||||
public AjaxResult save(Menu menu)
|
||||
public AjaxResult addSave(Menu menu)
|
||||
{
|
||||
if (menuService.saveMenu(menu) > 0)
|
||||
{
|
||||
return success();
|
||||
}
|
||||
return error();
|
||||
return toAjax(menuService.insertMenu(menu));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改菜单
|
||||
*/
|
||||
@GetMapping("/edit/{menuId}")
|
||||
public String edit(@PathVariable("menuId") Long menuId, ModelMap mmap)
|
||||
{
|
||||
mmap.put("menu", menuService.selectMenuById(menuId));
|
||||
return prefix + "/edit";
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改保存菜单
|
||||
*/
|
||||
@Log(title = "菜单管理", action = BusinessType.UPDATE)
|
||||
@RequiresPermissions("system:menu:edit")
|
||||
@PostMapping("/edit")
|
||||
@ResponseBody
|
||||
public AjaxResult editSave(Menu menu)
|
||||
{
|
||||
return toAjax(menuService.updateMenu(menu));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -176,9 +175,9 @@ public class MenuController extends BaseController
|
||||
* 选择菜单树
|
||||
*/
|
||||
@GetMapping("/selectMenuTree/{menuId}")
|
||||
public String selectMenuTree(@PathVariable("menuId") Long menuId, Model model)
|
||||
public String selectMenuTree(@PathVariable("menuId") Long menuId, ModelMap mmap)
|
||||
{
|
||||
model.addAttribute("treeName", menuService.selectMenuById(menuId).getMenuName());
|
||||
mmap.put("treeName", menuService.selectMenuById(menuId).getMenuName());
|
||||
return prefix + "/tree";
|
||||
}
|
||||
}
|
@ -100,12 +100,20 @@ public interface IMenuService
|
||||
public int selectCountRoleMenuByMenuId(Long menuId);
|
||||
|
||||
/**
|
||||
* 保存菜单信息
|
||||
* 新增保存菜单信息
|
||||
*
|
||||
* @param menu 菜单信息
|
||||
* @return 结果
|
||||
*/
|
||||
public int saveMenu(Menu menu);
|
||||
public int insertMenu(Menu menu);
|
||||
|
||||
/**
|
||||
* 修改保存菜单信息
|
||||
*
|
||||
* @param menu 菜单信息
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateMenu(Menu menu);
|
||||
|
||||
/**
|
||||
* 校验菜单名称是否唯一
|
||||
|
@ -25,7 +25,7 @@ import com.ruoyi.project.system.role.mapper.RoleMenuMapper;
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
@Service("menuService")
|
||||
@Service
|
||||
public class MenuServiceImpl implements IMenuService
|
||||
{
|
||||
public static final String PREMISSION_STRING = "perms[\"{0}\"]";
|
||||
@ -245,27 +245,31 @@ public class MenuServiceImpl implements IMenuService
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存菜单信息
|
||||
* 新增保存菜单信息
|
||||
*
|
||||
* @param menu 菜单信息
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int saveMenu(Menu menu)
|
||||
public int insertMenu(Menu menu)
|
||||
{
|
||||
Long menuId = menu.getMenuId();
|
||||
if (StringUtils.isNotNull(menuId))
|
||||
{
|
||||
menu.setUpdateBy(ShiroUtils.getLoginName());
|
||||
ShiroUtils.clearCachedAuthorizationInfo();
|
||||
return menuMapper.updateMenu(menu);
|
||||
}
|
||||
else
|
||||
{
|
||||
menu.setCreateBy(ShiroUtils.getLoginName());
|
||||
ShiroUtils.clearCachedAuthorizationInfo();
|
||||
return menuMapper.insertMenu(menu);
|
||||
}
|
||||
menu.setCreateBy(ShiroUtils.getLoginName());
|
||||
ShiroUtils.clearCachedAuthorizationInfo();
|
||||
return menuMapper.insertMenu(menu);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改保存菜单信息
|
||||
*
|
||||
* @param menu 菜单信息
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int updateMenu(Menu menu)
|
||||
{
|
||||
menu.setUpdateBy(ShiroUtils.getLoginName());
|
||||
ShiroUtils.clearCachedAuthorizationInfo();
|
||||
return menuMapper.updateMenu(menu);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -277,14 +281,9 @@ public class MenuServiceImpl implements IMenuService
|
||||
@Override
|
||||
public String checkMenuNameUnique(Menu menu)
|
||||
{
|
||||
if (menu.getMenuId() == null)
|
||||
{
|
||||
menu.setMenuId(-1L);
|
||||
}
|
||||
Long menuId = menu.getMenuId();
|
||||
Long menuId = StringUtils.isNull(menu.getMenuId()) ? -1L : menu.getMenuId();
|
||||
Menu info = menuMapper.checkMenuNameUnique(menu.getMenuName());
|
||||
if (StringUtils.isNotNull(info) && StringUtils.isNotNull(info.getMenuId())
|
||||
&& info.getMenuId().longValue() != menuId.longValue())
|
||||
if (StringUtils.isNotNull(info) && info.getMenuId().longValue() != menuId.longValue())
|
||||
{
|
||||
return UserConstants.MENU_NAME_NOT_UNIQUE;
|
||||
}
|
||||
|
@ -4,19 +4,19 @@ import java.util.List;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.ui.ModelMap;
|
||||
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.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import com.ruoyi.project.system.notice.domain.Notice;
|
||||
import com.ruoyi.project.system.notice.service.INoticeService;
|
||||
import com.ruoyi.framework.aspectj.lang.annotation.Log;
|
||||
import com.ruoyi.framework.aspectj.lang.constant.BusinessType;
|
||||
import com.ruoyi.framework.web.controller.BaseController;
|
||||
import com.ruoyi.framework.web.page.TableDataInfo;
|
||||
import com.ruoyi.framework.web.domain.AjaxResult;
|
||||
import com.ruoyi.framework.web.page.TableDataInfo;
|
||||
import com.ruoyi.project.system.notice.domain.Notice;
|
||||
import com.ruoyi.project.system.notice.service.INoticeService;
|
||||
|
||||
/**
|
||||
* 公告 信息操作处理
|
||||
@ -55,41 +55,44 @@ public class NoticeController extends BaseController
|
||||
/**
|
||||
* 新增公告
|
||||
*/
|
||||
@RequiresPermissions("system:notice:add")
|
||||
@Log(title = "通知公告", action = BusinessType.INSERT)
|
||||
@GetMapping("/add")
|
||||
public String add()
|
||||
{
|
||||
return prefix + "/add";
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增保存公告
|
||||
*/
|
||||
@RequiresPermissions("system:notice:add")
|
||||
@Log(title = "通知公告", action = BusinessType.INSERT)
|
||||
@PostMapping("/add")
|
||||
@ResponseBody
|
||||
public AjaxResult addSave(Notice notice)
|
||||
{
|
||||
return toAjax(noticeService.insertNotice(notice));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改公告
|
||||
*/
|
||||
@RequiresPermissions("system:notice:edit")
|
||||
@Log(title = "通知公告", action = BusinessType.UPDATE)
|
||||
@GetMapping("/edit/{noticeId}")
|
||||
public String edit(@PathVariable("noticeId") Integer noticeId, Model model)
|
||||
public String edit(@PathVariable("noticeId") Long noticeId, ModelMap mmap)
|
||||
{
|
||||
Notice notice = noticeService.selectNoticeById(noticeId);
|
||||
model.addAttribute("notice", notice);
|
||||
mmap.put("notice", noticeService.selectNoticeById(noticeId));
|
||||
return prefix + "/edit";
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存公告
|
||||
* 修改保存公告
|
||||
*/
|
||||
@RequiresPermissions("system:notice:save")
|
||||
@Log(title = "通知公告", action = BusinessType.SAVE)
|
||||
@PostMapping("/save")
|
||||
@RequiresPermissions("system:notice:edit")
|
||||
@Log(title = "通知公告", action = BusinessType.UPDATE)
|
||||
@PostMapping("/edit")
|
||||
@ResponseBody
|
||||
public AjaxResult save(Notice notice)
|
||||
public AjaxResult editSave(Notice notice)
|
||||
{
|
||||
if (noticeService.saveNotice(notice) > 0)
|
||||
{
|
||||
return success();
|
||||
}
|
||||
return error();
|
||||
return toAjax(noticeService.updateNotice(notice));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -101,12 +104,7 @@ public class NoticeController extends BaseController
|
||||
@ResponseBody
|
||||
public AjaxResult remove(String ids)
|
||||
{
|
||||
int rows = noticeService.deleteNoticeByIds(ids);
|
||||
if (rows > 0)
|
||||
{
|
||||
return success();
|
||||
}
|
||||
return error();
|
||||
return toAjax(noticeService.deleteNoticeByIds(ids));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ public class Notice extends BaseEntity
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 公告ID */
|
||||
private Integer noticeId;
|
||||
private Long noticeId;
|
||||
/** 公告标题 */
|
||||
private String noticeTitle;
|
||||
/** 公告类型(1通知 2公告) */
|
||||
@ -22,16 +22,16 @@ public class Notice extends BaseEntity
|
||||
/** 公告状态(0正常 1关闭) */
|
||||
private String status;
|
||||
|
||||
public void setNoticeId(Integer noticeId)
|
||||
{
|
||||
this.noticeId = noticeId;
|
||||
}
|
||||
|
||||
public Integer getNoticeId()
|
||||
public Long getNoticeId()
|
||||
{
|
||||
return noticeId;
|
||||
}
|
||||
|
||||
public void setNoticeId(Long noticeId)
|
||||
{
|
||||
this.noticeId = noticeId;
|
||||
}
|
||||
|
||||
public void setNoticeTitle(String noticeTitle)
|
||||
{
|
||||
this.noticeTitle = noticeTitle;
|
||||
|
@ -16,7 +16,7 @@ public interface NoticeMapper
|
||||
* @param noticeId 公告ID
|
||||
* @return 公告信息
|
||||
*/
|
||||
public Notice selectNoticeById(Integer noticeId);
|
||||
public Notice selectNoticeById(Long noticeId);
|
||||
|
||||
/**
|
||||
* 查询公告列表
|
||||
|
@ -16,7 +16,7 @@ public interface INoticeService
|
||||
* @param noticeId 公告ID
|
||||
* @return 公告信息
|
||||
*/
|
||||
public Notice selectNoticeById(Integer noticeId);
|
||||
public Notice selectNoticeById(Long noticeId);
|
||||
|
||||
/**
|
||||
* 查询公告列表
|
||||
@ -42,14 +42,6 @@ public interface INoticeService
|
||||
*/
|
||||
public int updateNotice(Notice notice);
|
||||
|
||||
/**
|
||||
* 保存公告
|
||||
*
|
||||
* @param notice 公告信息
|
||||
* @return 结果
|
||||
*/
|
||||
public int saveNotice(Notice notice);
|
||||
|
||||
/**
|
||||
* 删除公告信息
|
||||
*
|
||||
|
@ -3,7 +3,6 @@ package com.ruoyi.project.system.notice.service;
|
||||
import java.util.List;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.common.utils.security.ShiroUtils;
|
||||
import com.ruoyi.project.system.notice.mapper.NoticeMapper;
|
||||
import com.ruoyi.project.system.notice.domain.Notice;
|
||||
@ -29,7 +28,7 @@ public class NoticeServiceImpl implements INoticeService
|
||||
* @return 公告信息
|
||||
*/
|
||||
@Override
|
||||
public Notice selectNoticeById(Integer noticeId)
|
||||
public Notice selectNoticeById(Long noticeId)
|
||||
{
|
||||
return noticeMapper.selectNoticeById(noticeId);
|
||||
}
|
||||
@ -55,6 +54,7 @@ public class NoticeServiceImpl implements INoticeService
|
||||
@Override
|
||||
public int insertNotice(Notice notice)
|
||||
{
|
||||
notice.setCreateBy(ShiroUtils.getLoginName());
|
||||
return noticeMapper.insertNotice(notice);
|
||||
}
|
||||
|
||||
@ -67,35 +67,10 @@ public class NoticeServiceImpl implements INoticeService
|
||||
@Override
|
||||
public int updateNotice(Notice notice)
|
||||
{
|
||||
notice.setUpdateBy(ShiroUtils.getLoginName());
|
||||
return noticeMapper.updateNotice(notice);
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存公告
|
||||
*
|
||||
* @param notice 公告信息
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int saveNotice(Notice notice)
|
||||
{
|
||||
Integer noticeId = notice.getNoticeId();
|
||||
int rows = 0;
|
||||
if (StringUtils.isNotNull(noticeId))
|
||||
{
|
||||
notice.setUpdateBy(ShiroUtils.getLoginName());
|
||||
// 修改公告
|
||||
rows = noticeMapper.updateNotice(notice);
|
||||
}
|
||||
else
|
||||
{
|
||||
notice.setCreateBy(ShiroUtils.getLoginName());
|
||||
// 新增公告
|
||||
rows = noticeMapper.insertNotice(notice);
|
||||
}
|
||||
return rows;
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除公告对象
|
||||
*
|
||||
|
@ -4,7 +4,7 @@ import java.util.List;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.ui.ModelMap;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
@ -75,8 +75,7 @@ public class PostController extends BaseController
|
||||
{
|
||||
try
|
||||
{
|
||||
postService.deletePostByIds(ids);
|
||||
return success();
|
||||
return toAjax(postService.deletePostByIds(ids));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@ -87,41 +86,44 @@ public class PostController extends BaseController
|
||||
/**
|
||||
* 新增岗位
|
||||
*/
|
||||
@Log(title = "岗位管理", action = BusinessType.INSERT)
|
||||
@RequiresPermissions("system:post:add")
|
||||
@GetMapping("/add")
|
||||
public String add(Model model)
|
||||
public String add()
|
||||
{
|
||||
return prefix + "/add";
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增保存岗位
|
||||
*/
|
||||
@RequiresPermissions("system:post:add")
|
||||
@Log(title = "岗位管理", action = BusinessType.INSERT)
|
||||
@PostMapping("/add")
|
||||
@ResponseBody
|
||||
public AjaxResult addSave(Post post)
|
||||
{
|
||||
return toAjax(postService.insertPost(post));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改岗位
|
||||
*/
|
||||
@Log(title = "岗位管理", action = BusinessType.UPDATE)
|
||||
@RequiresPermissions("system:post:edit")
|
||||
@GetMapping("/edit/{postId}")
|
||||
public String edit(@PathVariable("postId") Long postId, Model model)
|
||||
public String edit(@PathVariable("postId") Long postId, ModelMap mmap)
|
||||
{
|
||||
Post post = postService.selectPostById(postId);
|
||||
model.addAttribute("post", post);
|
||||
mmap.put("post", postService.selectPostById(postId));
|
||||
return prefix + "/edit";
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存岗位
|
||||
* 修改保存岗位
|
||||
*/
|
||||
@Log(title = "岗位管理", action = BusinessType.SAVE)
|
||||
@RequiresPermissions("system:post:save")
|
||||
@PostMapping("/save")
|
||||
@RequiresPermissions("system:post:edit")
|
||||
@Log(title = "岗位管理", action = BusinessType.UPDATE)
|
||||
@PostMapping("/edit")
|
||||
@ResponseBody
|
||||
public AjaxResult save(Post post)
|
||||
public AjaxResult editSave(Post post)
|
||||
{
|
||||
if (postService.savePost(post) > 0)
|
||||
{
|
||||
return success();
|
||||
}
|
||||
return error();
|
||||
return toAjax(postService.updatePost(post));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -42,14 +42,6 @@ public interface PostMapper
|
||||
*/
|
||||
public Post selectPostById(Long postId);
|
||||
|
||||
/**
|
||||
* 通过岗位ID删除岗位信息
|
||||
*
|
||||
* @param postId 岗位ID
|
||||
* @return 结果
|
||||
*/
|
||||
public int deletePostById(Long postId);
|
||||
|
||||
/**
|
||||
* 批量删除岗位信息
|
||||
*
|
||||
|
@ -41,29 +41,29 @@ public interface IPostService
|
||||
*/
|
||||
public Post selectPostById(Long postId);
|
||||
|
||||
/**
|
||||
* 通过岗位ID删除岗位信息
|
||||
*
|
||||
* @param postId 岗位ID
|
||||
* @return 结果
|
||||
*/
|
||||
public boolean deletePostById(Long postId);
|
||||
|
||||
/**
|
||||
* 批量删除岗位信息
|
||||
*
|
||||
* @param ids 需要删除的数据ID
|
||||
*/
|
||||
public void deletePostByIds(String ids) throws Exception;
|
||||
public int deletePostByIds(String ids) throws Exception;
|
||||
|
||||
/**
|
||||
* 保存岗位信息
|
||||
* 新增保存岗位信息
|
||||
*
|
||||
* @param post 岗位信息
|
||||
* @return 结果
|
||||
*/
|
||||
public int savePost(Post post);
|
||||
|
||||
public int insertPost(Post post);
|
||||
|
||||
/**
|
||||
* 修改保存岗位信息
|
||||
*
|
||||
* @param post 岗位信息
|
||||
* @return 结果
|
||||
*/
|
||||
public int updatePost(Post post);
|
||||
|
||||
/**
|
||||
* 通过岗位ID查询岗位使用数量
|
||||
*
|
||||
|
@ -3,9 +3,7 @@ package com.ruoyi.project.system.post.service;
|
||||
import java.util.List;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.ruoyi.common.support.Convert;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.common.utils.security.ShiroUtils;
|
||||
import com.ruoyi.project.system.post.domain.Post;
|
||||
import com.ruoyi.project.system.post.mapper.PostMapper;
|
||||
@ -16,7 +14,7 @@ import com.ruoyi.project.system.user.mapper.UserPostMapper;
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
@Service("postService")
|
||||
@Service
|
||||
public class PostServiceImpl implements IPostService
|
||||
{
|
||||
@Autowired
|
||||
@ -85,18 +83,6 @@ public class PostServiceImpl implements IPostService
|
||||
return postMapper.selectPostById(postId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过岗位ID删除岗位信息
|
||||
*
|
||||
* @param postId 岗位ID
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public boolean deletePostById(Long postId)
|
||||
{
|
||||
return postMapper.deletePostById(postId) > 0 ? true : false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除岗位信息
|
||||
*
|
||||
@ -104,7 +90,7 @@ public class PostServiceImpl implements IPostService
|
||||
* @throws Exception
|
||||
*/
|
||||
@Override
|
||||
public void deletePostByIds(String ids) throws Exception
|
||||
public int deletePostByIds(String ids) throws Exception
|
||||
{
|
||||
Long[] postIds = Convert.toLongArray(ids);
|
||||
for (Long postId : postIds)
|
||||
@ -115,33 +101,33 @@ public class PostServiceImpl implements IPostService
|
||||
throw new Exception(String.format("%1$s已分配,不能删除", post.getPostName()));
|
||||
}
|
||||
}
|
||||
postMapper.deletePostByIds(postIds);
|
||||
return postMapper.deletePostByIds(postIds);
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存岗位信息
|
||||
* 新增保存岗位信息
|
||||
*
|
||||
* @param post 岗位信息
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int savePost(Post post)
|
||||
public int insertPost(Post post)
|
||||
{
|
||||
Long postId = post.getPostId();
|
||||
int count = 0;
|
||||
if (StringUtils.isNotNull(postId))
|
||||
{
|
||||
post.setUpdateBy(ShiroUtils.getLoginName());
|
||||
// 修改岗位信息
|
||||
count = postMapper.updatePost(post);
|
||||
}
|
||||
else
|
||||
{
|
||||
post.setCreateBy(ShiroUtils.getLoginName());
|
||||
// 新增岗位信息
|
||||
count = postMapper.insertPost(post);
|
||||
}
|
||||
return count;
|
||||
post.setCreateBy(ShiroUtils.getLoginName());
|
||||
return postMapper.insertPost(post);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改保存岗位信息
|
||||
*
|
||||
* @param post 岗位信息
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int updatePost(Post post)
|
||||
{
|
||||
post.setUpdateBy(ShiroUtils.getLoginName());
|
||||
return postMapper.updatePost(post);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -5,7 +5,7 @@ import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.ui.ModelMap;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
@ -72,42 +72,47 @@ public class RoleController extends BaseController
|
||||
/**
|
||||
* 新增角色
|
||||
*/
|
||||
@RequiresPermissions("system:role:add")
|
||||
@Log(title = "角色管理", action = BusinessType.INSERT)
|
||||
@GetMapping("/add")
|
||||
public String add(Model model)
|
||||
public String add()
|
||||
{
|
||||
return prefix + "/add";
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增保存角色
|
||||
*/
|
||||
@RequiresPermissions("system:role:add")
|
||||
@Log(title = "角色管理", action = BusinessType.INSERT)
|
||||
@PostMapping("/add")
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@ResponseBody
|
||||
public AjaxResult addSave(Role role)
|
||||
{
|
||||
return toAjax(roleService.insertRole(role));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改角色
|
||||
*/
|
||||
@RequiresPermissions("system:role:edit")
|
||||
@Log(title = "角色管理", action = BusinessType.UPDATE)
|
||||
@GetMapping("/edit/{roleId}")
|
||||
public String edit(@PathVariable("roleId") Long roleId, Model model)
|
||||
public String edit(@PathVariable("roleId") Long roleId, ModelMap mmap)
|
||||
{
|
||||
Role role = roleService.selectRoleById(roleId);
|
||||
model.addAttribute("role", role);
|
||||
mmap.put("role", roleService.selectRoleById(roleId));
|
||||
return prefix + "/edit";
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存角色
|
||||
* 修改保存角色
|
||||
*/
|
||||
@RequiresPermissions("system:role:save")
|
||||
@Log(title = "角色管理", action = BusinessType.SAVE)
|
||||
@PostMapping("/save")
|
||||
@RequiresPermissions("system:role:edit")
|
||||
@Log(title = "角色管理", action = BusinessType.UPDATE)
|
||||
@PostMapping("/edit")
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@ResponseBody
|
||||
public AjaxResult save(Role role)
|
||||
public AjaxResult editSave(Role role)
|
||||
{
|
||||
if (roleService.saveRole(role) > 0)
|
||||
{
|
||||
return success();
|
||||
}
|
||||
return error();
|
||||
return toAjax(roleService.updateRole(role));
|
||||
}
|
||||
|
||||
@RequiresPermissions("system:role:remove")
|
||||
@ -118,8 +123,7 @@ public class RoleController extends BaseController
|
||||
{
|
||||
try
|
||||
{
|
||||
roleService.deleteRoleByIds(ids);
|
||||
return success();
|
||||
return toAjax(roleService.deleteRoleByIds(ids));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
@ -64,16 +64,24 @@ public interface IRoleService
|
||||
*
|
||||
* @param ids 需要删除的数据ID
|
||||
*/
|
||||
public void deleteRoleByIds(String ids) throws Exception;
|
||||
public int deleteRoleByIds(String ids) throws Exception;
|
||||
|
||||
/**
|
||||
* 保存角色信息
|
||||
* 新增保存角色信息
|
||||
*
|
||||
* @param role 角色信息
|
||||
* @return 结果
|
||||
*/
|
||||
public int saveRole(Role role);
|
||||
|
||||
public int insertRole(Role role);
|
||||
|
||||
/**
|
||||
* 修改保存角色信息
|
||||
*
|
||||
* @param role 角色信息
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateRole(Role role);
|
||||
|
||||
/**
|
||||
* 校验角色名称是否唯一
|
||||
*
|
||||
@ -81,7 +89,7 @@ public interface IRoleService
|
||||
* @return 结果
|
||||
*/
|
||||
public String checkRoleNameUnique(Role role);
|
||||
|
||||
|
||||
/**
|
||||
* 通过角色ID查询角色使用数量
|
||||
*
|
||||
|
@ -22,7 +22,7 @@ import com.ruoyi.project.system.user.mapper.UserRoleMapper;
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
@Service("roleService")
|
||||
@Service
|
||||
public class RoleServiceImpl implements IRoleService
|
||||
{
|
||||
|
||||
@ -135,7 +135,7 @@ public class RoleServiceImpl implements IRoleService
|
||||
* @throws Exception
|
||||
*/
|
||||
@Override
|
||||
public void deleteRoleByIds(String ids) throws Exception
|
||||
public int deleteRoleByIds(String ids) throws Exception
|
||||
{
|
||||
Long[] roleIds = Convert.toLongArray(ids);
|
||||
for (Long roleId : roleIds)
|
||||
@ -146,33 +146,39 @@ public class RoleServiceImpl implements IRoleService
|
||||
throw new Exception(String.format("%1$s已分配,不能删除", role.getRoleName()));
|
||||
}
|
||||
}
|
||||
roleMapper.deleteRoleByIds(roleIds);
|
||||
return roleMapper.deleteRoleByIds(roleIds);
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存角色信息
|
||||
* 新增保存角色信息
|
||||
*
|
||||
* @param role 角色信息
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int saveRole(Role role)
|
||||
public int insertRole(Role role)
|
||||
{
|
||||
Long roleId = role.getRoleId();
|
||||
if (StringUtils.isNotNull(roleId))
|
||||
{
|
||||
role.setUpdateBy(ShiroUtils.getLoginName());
|
||||
// 修改角色信息
|
||||
roleMapper.updateRole(role);
|
||||
// 删除角色与菜单关联
|
||||
roleMenuMapper.deleteRoleMenuByRoleId(roleId);
|
||||
}
|
||||
else
|
||||
{
|
||||
role.setCreateBy(ShiroUtils.getLoginName());
|
||||
// 新增角色信息
|
||||
roleMapper.insertRole(role);
|
||||
}
|
||||
role.setCreateBy(ShiroUtils.getLoginName());
|
||||
// 新增角色信息
|
||||
roleMapper.insertRole(role);
|
||||
ShiroUtils.clearCachedAuthorizationInfo();
|
||||
return insertRoleMenu(role);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改保存角色信息
|
||||
*
|
||||
* @param role 角色信息
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int updateRole(Role role)
|
||||
{
|
||||
role.setUpdateBy(ShiroUtils.getLoginName());
|
||||
// 修改角色信息
|
||||
roleMapper.updateRole(role);
|
||||
// 删除角色与菜单关联
|
||||
roleMenuMapper.deleteRoleMenuByRoleId(role.getRoleId());
|
||||
ShiroUtils.clearCachedAuthorizationInfo();
|
||||
return insertRoleMenu(role);
|
||||
}
|
||||
@ -210,13 +216,9 @@ public class RoleServiceImpl implements IRoleService
|
||||
@Override
|
||||
public String checkRoleNameUnique(Role role)
|
||||
{
|
||||
if (role.getRoleId() == null)
|
||||
{
|
||||
role.setRoleId(-1L);
|
||||
}
|
||||
Long roleId = role.getRoleId();
|
||||
Long roleId = StringUtils.isNull(role.getRoleId()) ? -1L : role.getRoleId();
|
||||
Role info = roleMapper.checkRoleNameUnique(role.getRoleName());
|
||||
if (StringUtils.isNotNull(info) && StringUtils.isNotNull(info.getRoleId()) && info.getRoleId() != roleId)
|
||||
if (StringUtils.isNotNull(info) && info.getRoleId().longValue() != roleId.longValue())
|
||||
{
|
||||
return UserConstants.ROLE_NAME_NOT_UNIQUE;
|
||||
}
|
||||
|
@ -3,7 +3,7 @@ package com.ruoyi.project.system.user.controller;
|
||||
import java.util.List;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.ui.ModelMap;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import com.ruoyi.framework.config.RuoYiConfig;
|
||||
import com.ruoyi.framework.web.controller.BaseController;
|
||||
@ -27,23 +27,23 @@ public class IndexController extends BaseController
|
||||
|
||||
// 系统首页
|
||||
@GetMapping("/index")
|
||||
public String index(Model model)
|
||||
public String index(ModelMap mmap)
|
||||
{
|
||||
// 取身份信息
|
||||
User user = getUser();
|
||||
// 根据用户id取出菜单
|
||||
List<Menu> menus = menuService.selectMenusByUserId(user.getUserId());
|
||||
model.addAttribute("menus", menus);
|
||||
model.addAttribute("user", user);
|
||||
model.addAttribute("copyrightYear", ruoYiConfig.getCopyrightYear());
|
||||
mmap.put("menus", menus);
|
||||
mmap.put("user", user);
|
||||
mmap.put("copyrightYear", ruoYiConfig.getCopyrightYear());
|
||||
return "index";
|
||||
}
|
||||
|
||||
// 系统介绍
|
||||
@GetMapping("/system/main")
|
||||
public String main(Model model)
|
||||
public String main(ModelMap mmap)
|
||||
{
|
||||
model.addAttribute("version", ruoYiConfig.getVersion());
|
||||
mmap.put("version", ruoYiConfig.getVersion());
|
||||
return "main";
|
||||
}
|
||||
|
||||
|
@ -7,7 +7,6 @@ import org.apache.shiro.authc.AuthenticationException;
|
||||
import org.apache.shiro.authc.UsernamePasswordToken;
|
||||
import org.apache.shiro.subject.Subject;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
@ -26,7 +25,7 @@ public class LoginController extends BaseController
|
||||
{
|
||||
|
||||
@GetMapping("/login")
|
||||
public String login(HttpServletRequest request, HttpServletResponse response, Model model)
|
||||
public String login(HttpServletRequest request, HttpServletResponse response)
|
||||
{
|
||||
// 如果是Ajax请求,返回Json字符串。
|
||||
if (ServletUtils.isAjaxRequest((HttpServletRequest) request))
|
||||
|
@ -5,7 +5,7 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.ui.ModelMap;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
@ -18,6 +18,7 @@ import com.ruoyi.framework.aspectj.lang.annotation.Log;
|
||||
import com.ruoyi.framework.aspectj.lang.constant.BusinessType;
|
||||
import com.ruoyi.framework.web.controller.BaseController;
|
||||
import com.ruoyi.framework.web.domain.AjaxResult;
|
||||
import com.ruoyi.framework.web.service.DictService;
|
||||
import com.ruoyi.project.system.user.domain.User;
|
||||
import com.ruoyi.project.system.user.service.IUserService;
|
||||
|
||||
@ -37,27 +38,20 @@ public class ProfileController extends BaseController
|
||||
@Autowired
|
||||
private IUserService userService;
|
||||
|
||||
@Autowired
|
||||
private DictService dict;
|
||||
|
||||
/**
|
||||
* 个人信息
|
||||
*/
|
||||
@GetMapping()
|
||||
public String profile(Model model)
|
||||
public String profile(ModelMap mmap)
|
||||
{
|
||||
User user = getUser();
|
||||
String sex = user.getSex();
|
||||
if ("0".equals(sex))
|
||||
{
|
||||
user.setSex("性别:男");
|
||||
}
|
||||
else if ("1".equals(sex))
|
||||
{
|
||||
user.setSex("性别:女");
|
||||
}
|
||||
String roleGroup = userService.selectUserRoleGroup(user.getUserId());
|
||||
String postGroup = userService.selectUserPostGroup(user.getUserId());
|
||||
model.addAttribute("user", user);
|
||||
model.addAttribute("roleGroup", roleGroup);
|
||||
model.addAttribute("postGroup", postGroup);
|
||||
user.setSex(dict.getLabel("sys_user_sex", user.getSex()));
|
||||
mmap.put("user", user);
|
||||
mmap.put("roleGroup", userService.selectUserRoleGroup(user.getUserId()));
|
||||
mmap.put("postGroup", userService.selectUserPostGroup(user.getUserId()));
|
||||
return prefix + "/profile";
|
||||
}
|
||||
|
||||
@ -75,10 +69,9 @@ public class ProfileController extends BaseController
|
||||
}
|
||||
|
||||
@GetMapping("/resetPwd/{userId}")
|
||||
public String resetPwd(@PathVariable("userId") Long userId, Model model)
|
||||
public String resetPwd(@PathVariable("userId") Long userId, ModelMap mmap)
|
||||
{
|
||||
User user = userService.selectUserById(userId);
|
||||
model.addAttribute("user", user);
|
||||
mmap.put("user", userService.selectUserById(userId));
|
||||
return prefix + "/resetPwd";
|
||||
}
|
||||
|
||||
@ -99,36 +92,32 @@ public class ProfileController extends BaseController
|
||||
/**
|
||||
* 修改用户
|
||||
*/
|
||||
@Log(title = "个人信息", action = BusinessType.UPDATE)
|
||||
@GetMapping("/edit/{userId}")
|
||||
public String edit(@PathVariable("userId") Long userId, Model model)
|
||||
public String edit(@PathVariable("userId") Long userId, ModelMap mmap)
|
||||
{
|
||||
User user = userService.selectUserById(userId);
|
||||
model.addAttribute("user", user);
|
||||
mmap.put("user", userService.selectUserById(userId));
|
||||
return prefix + "/edit";
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改头像
|
||||
*/
|
||||
@Log(title = "个人信息", action = BusinessType.UPDATE)
|
||||
@GetMapping("/avatar/{userId}")
|
||||
public String avatar(@PathVariable("userId") Long userId, Model model)
|
||||
public String avatar(@PathVariable("userId") Long userId, ModelMap mmap)
|
||||
{
|
||||
User user = userService.selectUserById(userId);
|
||||
model.addAttribute("user", user);
|
||||
mmap.put("user", userService.selectUserById(userId));
|
||||
return prefix + "/avatar";
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改用户
|
||||
*/
|
||||
@Log(title = "个人信息", action = BusinessType.SAVE)
|
||||
@Log(title = "个人信息", action = BusinessType.UPDATE)
|
||||
@PostMapping("/update")
|
||||
@ResponseBody
|
||||
public AjaxResult update(User user)
|
||||
{
|
||||
if (userService.updateUser(user) > 0)
|
||||
if (userService.updateUserInfo(user) > 0)
|
||||
{
|
||||
setUser(userService.selectUserById(user.getUserId()));
|
||||
return success();
|
||||
@ -139,7 +128,7 @@ public class ProfileController extends BaseController
|
||||
/**
|
||||
* 保存头像
|
||||
*/
|
||||
@Log(title = "个人信息", action = BusinessType.SAVE)
|
||||
@Log(title = "个人信息", action = BusinessType.UPDATE)
|
||||
@PostMapping("/updateAvatar")
|
||||
@ResponseBody
|
||||
public AjaxResult updateAvatar(User user, @RequestParam("avatarfile") MultipartFile file)
|
||||
@ -150,7 +139,7 @@ public class ProfileController extends BaseController
|
||||
{
|
||||
String avatar = FileUploadUtils.upload(file);
|
||||
user.setAvatar(avatar);
|
||||
if (userService.updateUser(user) > 0)
|
||||
if (userService.updateUserInfo(user) > 0)
|
||||
{
|
||||
setUser(userService.selectUserById(user.getUserId()));
|
||||
return success();
|
||||
|
@ -1,5 +1,16 @@
|
||||
package com.ruoyi.project.system.user.controller;
|
||||
|
||||
import java.util.List;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.ui.ModelMap;
|
||||
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.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.common.utils.poi.ExcelUtil;
|
||||
import com.ruoyi.framework.aspectj.lang.annotation.Log;
|
||||
@ -7,19 +18,10 @@ import com.ruoyi.framework.aspectj.lang.constant.BusinessType;
|
||||
import com.ruoyi.framework.web.controller.BaseController;
|
||||
import com.ruoyi.framework.web.domain.AjaxResult;
|
||||
import com.ruoyi.framework.web.page.TableDataInfo;
|
||||
import com.ruoyi.project.system.post.domain.Post;
|
||||
import com.ruoyi.project.system.post.service.IPostService;
|
||||
import com.ruoyi.project.system.role.domain.Role;
|
||||
import com.ruoyi.project.system.role.service.IRoleService;
|
||||
import com.ruoyi.project.system.user.domain.User;
|
||||
import com.ruoyi.project.system.user.service.IUserService;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 用户信息
|
||||
@ -75,60 +77,79 @@ public class UserController extends BaseController
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增用户
|
||||
*/
|
||||
@GetMapping("/add")
|
||||
public String add(ModelMap mmap)
|
||||
{
|
||||
mmap.put("roles", roleService.selectRoleAll());
|
||||
mmap.put("posts", postService.selectPostAll());
|
||||
return prefix + "/add";
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增保存用户
|
||||
*/
|
||||
@RequiresPermissions("system:user:add")
|
||||
@Log(title = "用户管理", action = BusinessType.INSERT)
|
||||
@PostMapping("/add")
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@ResponseBody
|
||||
public AjaxResult addSave(User user)
|
||||
{
|
||||
if (StringUtils.isNotNull(user.getUserId()) && User.isAdmin(user.getUserId()))
|
||||
{
|
||||
return error("不允许修改超级管理员用户");
|
||||
}
|
||||
return toAjax(userService.insertUser(user));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改用户
|
||||
*/
|
||||
@RequiresPermissions("system:user:edit")
|
||||
@Log(title = "用户管理", action = BusinessType.UPDATE)
|
||||
@GetMapping("/edit/{userId}")
|
||||
public String edit(@PathVariable("userId") Long userId, Model model)
|
||||
public String edit(@PathVariable("userId") Long userId, ModelMap mmap)
|
||||
{
|
||||
User user = userService.selectUserById(userId);
|
||||
List<Role> roles = roleService.selectRolesByUserId(userId);
|
||||
List<Post> posts = postService.selectPostsByUserId(userId);
|
||||
model.addAttribute("roles", roles);
|
||||
model.addAttribute("posts", posts);
|
||||
model.addAttribute("user", user);
|
||||
mmap.put("user", userService.selectUserById(userId));
|
||||
mmap.put("roles", roleService.selectRolesByUserId(userId));
|
||||
mmap.put("posts", postService.selectPostsByUserId(userId));
|
||||
return prefix + "/edit";
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增用户
|
||||
* 修改保存用户
|
||||
*/
|
||||
@RequiresPermissions("system:user:add")
|
||||
@Log(title = "用户管理", action = BusinessType.INSERT)
|
||||
@GetMapping("/add")
|
||||
public String add(Model model)
|
||||
@RequiresPermissions("system:user:edit")
|
||||
@Log(title = "用户管理", action = BusinessType.UPDATE)
|
||||
@PostMapping("/edit")
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@ResponseBody
|
||||
public AjaxResult editSave(User user)
|
||||
{
|
||||
List<Role> roles = roleService.selectRoleAll();
|
||||
List<Post> posts = postService.selectPostAll();
|
||||
model.addAttribute("roles", roles);
|
||||
model.addAttribute("posts", posts);
|
||||
return prefix + "/add";
|
||||
if (StringUtils.isNotNull(user.getUserId()) && User.isAdmin(user.getUserId()))
|
||||
{
|
||||
return error("不允许修改超级管理员用户");
|
||||
}
|
||||
return toAjax(userService.updateUser(user));
|
||||
}
|
||||
|
||||
@RequiresPermissions("system:user:resetPwd")
|
||||
@Log(title = "重置密码", action = BusinessType.UPDATE)
|
||||
@GetMapping("/resetPwd/{userId}")
|
||||
public String resetPwd(@PathVariable("userId") Long userId, Model model)
|
||||
public String resetPwd(@PathVariable("userId") Long userId, ModelMap mmap)
|
||||
{
|
||||
User user = userService.selectUserById(userId);
|
||||
model.addAttribute("user", user);
|
||||
mmap.put("user", userService.selectUserById(userId));
|
||||
return prefix + "/resetPwd";
|
||||
}
|
||||
|
||||
@RequiresPermissions("system:user:resetPwd")
|
||||
@Log(title = "重置密码", action = BusinessType.SAVE)
|
||||
@Log(title = "重置密码", action = BusinessType.UPDATE)
|
||||
@PostMapping("/resetPwd")
|
||||
@ResponseBody
|
||||
public AjaxResult resetPwd(User user)
|
||||
{
|
||||
int rows = userService.resetUserPwd(user);
|
||||
if (rows > 0)
|
||||
{
|
||||
return success();
|
||||
}
|
||||
return error();
|
||||
return toAjax(userService.resetUserPwd(user));
|
||||
}
|
||||
|
||||
@RequiresPermissions("system:user:remove")
|
||||
@ -139,8 +160,7 @@ public class UserController extends BaseController
|
||||
{
|
||||
try
|
||||
{
|
||||
userService.deleteUserByIds(ids);
|
||||
return success();
|
||||
return toAjax(userService.deleteUserByIds(ids));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@ -148,23 +168,6 @@ public class UserController extends BaseController
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存用户
|
||||
*/
|
||||
@RequiresPermissions("system:user:save")
|
||||
@Log(title = "用户管理", action = BusinessType.SAVE)
|
||||
@PostMapping("/save")
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@ResponseBody
|
||||
public AjaxResult save(User user)
|
||||
{
|
||||
if (StringUtils.isNotNull(user.getUserId()) && User.isAdmin(user.getUserId()))
|
||||
{
|
||||
return error("不允许修改超级管理员用户");
|
||||
}
|
||||
return userService.saveUser(user) > 0 ? success() : error();
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验用户名
|
||||
*/
|
||||
|
@ -64,7 +64,7 @@ public interface IUserService
|
||||
*
|
||||
* @param ids 需要删除的数据ID
|
||||
*/
|
||||
public void deleteUserByIds(String ids) throws Exception;
|
||||
public int deleteUserByIds(String ids) throws Exception;
|
||||
|
||||
/**
|
||||
* 保存用户信息
|
||||
@ -72,16 +72,24 @@ public interface IUserService
|
||||
* @param user 用户信息
|
||||
* @return 结果
|
||||
*/
|
||||
public int saveUser(User user);
|
||||
public int insertUser(User user);
|
||||
|
||||
/**
|
||||
* 修改用户信息
|
||||
* 保存用户信息
|
||||
*
|
||||
* @param user 用户信息
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateUser(User user);
|
||||
|
||||
/**
|
||||
* 修改用户详细信息
|
||||
*
|
||||
* @param user 用户信息
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateUserInfo(User user);
|
||||
|
||||
/**
|
||||
* 修改用户密码信息
|
||||
*
|
||||
|
@ -25,7 +25,7 @@ import com.ruoyi.project.system.user.mapper.UserRoleMapper;
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
@Service("userService")
|
||||
@Service
|
||||
public class UserServiceImpl implements IUserService
|
||||
{
|
||||
@Autowired
|
||||
@ -130,7 +130,7 @@ public class UserServiceImpl implements IUserService
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public void deleteUserByIds(String ids) throws Exception
|
||||
public int deleteUserByIds(String ids) throws Exception
|
||||
{
|
||||
Long[] userIds = Convert.toLongArray(ids);
|
||||
for (Long userId : userIds)
|
||||
@ -140,58 +140,60 @@ public class UserServiceImpl implements IUserService
|
||||
throw new Exception("不允许删除超级管理员用户");
|
||||
}
|
||||
}
|
||||
userMapper.deleteUserByIds(userIds);
|
||||
return userMapper.deleteUserByIds(userIds);
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存用户信息
|
||||
* 新增保存用户信息
|
||||
*
|
||||
* @param user 用户信息
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int saveUser(User user)
|
||||
public int insertUser(User user)
|
||||
{
|
||||
int count = 0;
|
||||
Long userId = user.getUserId();
|
||||
if (StringUtils.isNotNull(userId))
|
||||
{
|
||||
user.setUpdateBy(ShiroUtils.getLoginName());
|
||||
// 修改用户信息
|
||||
count = updateUser(user);
|
||||
// 删除用户与角色关联
|
||||
userRoleMapper.deleteUserRoleByUserId(userId);
|
||||
// 新增用户与角色管理
|
||||
insertUserRole(user);
|
||||
// 删除用户与岗位关联
|
||||
userPostMapper.deleteUserPostByUserId(userId);
|
||||
// 新增用户与岗位管理
|
||||
insertUserPost(user);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
user.randomSalt();
|
||||
user.setPassword(passwordService.encryptPassword(user.getLoginName(), user.getPassword(), user.getSalt()));
|
||||
user.setCreateBy(ShiroUtils.getLoginName());
|
||||
// 新增用户信息
|
||||
count = userMapper.insertUser(user);
|
||||
// 新增用户岗位关联
|
||||
insertUserPost(user);
|
||||
// 新增用户与角色管理
|
||||
insertUserRole(user);
|
||||
}
|
||||
return count;
|
||||
user.randomSalt();
|
||||
user.setPassword(passwordService.encryptPassword(user.getLoginName(), user.getPassword(), user.getSalt()));
|
||||
user.setCreateBy(ShiroUtils.getLoginName());
|
||||
// 新增用户信息
|
||||
int rows = userMapper.insertUser(user);
|
||||
// 新增用户岗位关联
|
||||
insertUserPost(user);
|
||||
// 新增用户与角色管理
|
||||
insertUserRole(user);
|
||||
return rows;
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改用户信息
|
||||
* 修改保存用户信息
|
||||
*
|
||||
* @param user 用户信息
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int updateUser(User user)
|
||||
{
|
||||
Long userId = user.getUserId();
|
||||
user.setUpdateBy(ShiroUtils.getLoginName());
|
||||
// 删除用户与角色关联
|
||||
userRoleMapper.deleteUserRoleByUserId(userId);
|
||||
// 新增用户与角色管理
|
||||
insertUserRole(user);
|
||||
// 删除用户与岗位关联
|
||||
userPostMapper.deleteUserPostByUserId(userId);
|
||||
// 新增用户与岗位管理
|
||||
insertUserPost(user);
|
||||
return userMapper.updateUser(user);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改用户个人详细信息
|
||||
*
|
||||
* @param user 用户信息
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int updateUserInfo(User user)
|
||||
{
|
||||
return userMapper.updateUser(user);
|
||||
}
|
||||
@ -280,14 +282,9 @@ public class UserServiceImpl implements IUserService
|
||||
@Override
|
||||
public String checkPhoneUnique(User user)
|
||||
{
|
||||
if (user.getUserId() == null)
|
||||
{
|
||||
user.setUserId(-1L);
|
||||
}
|
||||
Long userId = user.getUserId();
|
||||
Long userId = StringUtils.isNull(user.getUserId()) ? -1L : user.getUserId();
|
||||
User info = userMapper.checkPhoneUnique(user.getPhonenumber());
|
||||
if (StringUtils.isNotNull(info) && StringUtils.isNotNull(info.getUserId())
|
||||
&& info.getUserId().longValue() != userId.longValue())
|
||||
if (StringUtils.isNotNull(info) && info.getUserId().longValue() != userId.longValue())
|
||||
{
|
||||
return UserConstants.USER_PHONE_NOT_UNIQUE;
|
||||
}
|
||||
@ -303,14 +300,9 @@ public class UserServiceImpl implements IUserService
|
||||
@Override
|
||||
public String checkEmailUnique(User user)
|
||||
{
|
||||
if (user.getUserId() == null)
|
||||
{
|
||||
user.setUserId(-1L);
|
||||
}
|
||||
Long userId = user.getUserId();
|
||||
Long userId = StringUtils.isNull(user.getUserId()) ? -1L : user.getUserId();
|
||||
User info = userMapper.checkEmailUnique(user.getEmail());
|
||||
if (StringUtils.isNotNull(info) && StringUtils.isNotNull(info.getUserId())
|
||||
&& info.getUserId().longValue() != userId.longValue())
|
||||
if (StringUtils.isNotNull(info) && info.getUserId().longValue() != userId.longValue())
|
||||
{
|
||||
return UserConstants.USER_EMAIL_NOT_UNIQUE;
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ import com.ruoyi.project.tool.gen.util.VelocityInitializer;
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
@Service("genService")
|
||||
@Service
|
||||
public class GenServiceImpl implements IGenService
|
||||
{
|
||||
@Autowired
|
||||
|
Reference in New Issue
Block a user