新增后台配置项
This commit is contained in:
parent
6b383f087d
commit
4e81ac3a92
|
|
@ -13,4 +13,5 @@ public interface PetRepository extends BaseRepository<Pet, Long> {
|
|||
|
||||
List<Pet> findAllByUid(long uid);
|
||||
|
||||
Pet findFirstById(Long id);
|
||||
}
|
||||
|
|
@ -13,6 +13,7 @@ import com.linln.admin.users.service.UsersAmountRecordsService;
|
|||
import com.linln.admin.users.service.UsersService;
|
||||
import com.linln.common.data.PageSort;
|
||||
import com.linln.common.enums.StatusEnum;
|
||||
import com.linln.component.thymeleaf.utility.DictUtil;
|
||||
import org.apache.shiro.config.Ini;
|
||||
import org.springframework.data.domain.Example;
|
||||
import org.springframework.data.domain.Page;
|
||||
|
|
@ -136,6 +137,9 @@ public class OrderMainServiceImpl implements OrderMainService {
|
|||
orderMain.setCoupons(coupons);
|
||||
}
|
||||
}
|
||||
Pet pet = petRepository.findFirstById(orderSub.getPetId());
|
||||
String petInfo = "宠物名称:" + pet.getNickName() + "</br>品种:" + InitLoadDataService.PET_BASE_INFO_MAP.get(pet.getPetId()).getAssortment() + "</br>体重:" + (InitLoadDataService.PET_BASE_INFO_MAP.get(pet.getPetId()).getPetType() == 1 ? DictUtil.petCatWeight(Byte.valueOf(pet.getWeight().toString())) : DictUtil.petDogWeight(Byte.valueOf(pet.getWeight().toString()))) + "</br>服务项目:" + orderSub.getGoods();
|
||||
orderSub.setPetInfo(petInfo);
|
||||
String str = "";
|
||||
if (orderSubs.size() > 1) {
|
||||
str = "<br><br>";
|
||||
|
|
|
|||
|
|
@ -0,0 +1,119 @@
|
|||
package com.linln.admin.users.controller;
|
||||
|
||||
import com.linln.admin.users.domain.Configs;
|
||||
import com.linln.admin.users.service.ConfigsService;
|
||||
import com.linln.admin.users.validator.ConfigsValid;
|
||||
import com.linln.common.enums.StatusEnum;
|
||||
import com.linln.common.utils.EntityBeanUtil;
|
||||
import com.linln.common.utils.ResultVoUtil;
|
||||
import com.linln.common.utils.StatusUtil;
|
||||
import com.linln.common.vo.ResultVo;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.springframework.data.domain.Example;
|
||||
import org.springframework.data.domain.ExampleMatcher;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* @author gion
|
||||
* @date 2024/12/17
|
||||
*/
|
||||
@Controller
|
||||
@RequestMapping("/users/configs")
|
||||
public class ConfigsController {
|
||||
|
||||
@Resource
|
||||
private ConfigsService configsService;
|
||||
|
||||
/**
|
||||
* 列表页面
|
||||
*/
|
||||
@GetMapping("/index")
|
||||
@RequiresPermissions("users:configs:index")
|
||||
public String index(Model model, Configs configs) {
|
||||
|
||||
// 创建匹配器,进行动态查询匹配
|
||||
ExampleMatcher matcher = ExampleMatcher.matching();
|
||||
|
||||
// 获取数据列表
|
||||
Example<Configs> example = Example.of(configs, matcher);
|
||||
Page<Configs> list = configsService.getPageList(example);
|
||||
|
||||
// 封装数据
|
||||
model.addAttribute("list", list.getContent());
|
||||
model.addAttribute("page", list);
|
||||
return "/users/configs/index";
|
||||
}
|
||||
|
||||
/**
|
||||
* 跳转到添加页面
|
||||
*/
|
||||
@GetMapping("/add")
|
||||
@RequiresPermissions("users:configs:add")
|
||||
public String toAdd() {
|
||||
return "/users/configs/add";
|
||||
}
|
||||
|
||||
/**
|
||||
* 跳转到编辑页面
|
||||
*/
|
||||
@GetMapping("/edit/{id}")
|
||||
@RequiresPermissions("users:configs:edit")
|
||||
public String toEdit(@PathVariable("id") Configs configs, Model model) {
|
||||
model.addAttribute("configs", configs);
|
||||
return "/users/configs/add";
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存添加/修改的数据
|
||||
* @param valid 验证对象
|
||||
*/
|
||||
@PostMapping("/save")
|
||||
@RequiresPermissions({"users:configs:add", "users:configs:edit"})
|
||||
@ResponseBody
|
||||
public ResultVo save(@Validated ConfigsValid valid, Configs configs) {
|
||||
// 复制保留无需修改的数据
|
||||
if (configs.getId() != null) {
|
||||
Configs beConfigs = configsService.getById(configs.getId());
|
||||
EntityBeanUtil.copyProperties(beConfigs, configs);
|
||||
}
|
||||
|
||||
// 保存数据
|
||||
configsService.save(configs);
|
||||
return ResultVoUtil.SAVE_SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
* 跳转到详细页面
|
||||
*/
|
||||
@GetMapping("/detail/{id}")
|
||||
@RequiresPermissions("users:configs:detail")
|
||||
public String toDetail(@PathVariable("id") Configs configs, Model model) {
|
||||
model.addAttribute("configs",configs);
|
||||
return "/users/configs/detail";
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置一条或者多条数据的状态
|
||||
*/
|
||||
@RequestMapping("/status/{param}")
|
||||
@RequiresPermissions("users:configs:status")
|
||||
@ResponseBody
|
||||
public ResultVo status(
|
||||
@PathVariable("param") String param,
|
||||
@RequestParam(value = "ids", required = false) List<Long> ids) {
|
||||
// 更新状态
|
||||
StatusEnum statusEnum = StatusUtil.getStatusEnum(param);
|
||||
if (configsService.updateStatus(statusEnum, ids)) {
|
||||
return ResultVoUtil.success(statusEnum.getMessage() + "成功");
|
||||
} else {
|
||||
return ResultVoUtil.error(statusEnum.getMessage() + "失败,请重新操作");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,70 @@
|
|||
package com.linln.admin.users.domain;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.linln.common.enums.StatusEnum;
|
||||
import com.linln.common.utils.StatusUtil;
|
||||
import com.linln.modules.system.domain.User;
|
||||
import lombok.Data;
|
||||
import org.hibernate.annotations.NotFound;
|
||||
import org.hibernate.annotations.NotFoundAction;
|
||||
import org.hibernate.annotations.Where;
|
||||
import org.springframework.data.annotation.CreatedDate;
|
||||
import org.springframework.data.annotation.LastModifiedBy;
|
||||
import org.springframework.data.annotation.LastModifiedDate;
|
||||
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.EntityListeners;
|
||||
import javax.persistence.FetchType;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.JoinColumn;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.Table;
|
||||
|
||||
/**
|
||||
* @author gion
|
||||
* @date 2024/12/17
|
||||
*/
|
||||
@Data
|
||||
@Entity
|
||||
@Table(name="system_configs")
|
||||
@EntityListeners(AuditingEntityListener.class)
|
||||
@Where(clause = StatusUtil.NOT_DELETE)
|
||||
public class Configs implements Serializable {
|
||||
// 主键ID
|
||||
@Id
|
||||
@GeneratedValue(strategy=GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
private String name;
|
||||
// 配置类型
|
||||
private String configType;
|
||||
// 内容
|
||||
private String content;
|
||||
// 排序
|
||||
private Integer sort;
|
||||
// 内容类型
|
||||
private Integer contentType;
|
||||
// 更新者
|
||||
@LastModifiedBy
|
||||
@ManyToOne(fetch=FetchType.LAZY)
|
||||
@NotFound(action=NotFoundAction.IGNORE)
|
||||
@JoinColumn(name="update_by")
|
||||
@JsonIgnore
|
||||
private User updateBy;
|
||||
// 数据状态
|
||||
private Byte status = StatusEnum.OK.getCode();
|
||||
// 跳转类型
|
||||
private Integer jumpType;
|
||||
// 跳转URL
|
||||
private String jumpUrl;
|
||||
// 创建时间
|
||||
@CreatedDate
|
||||
private Date createDate;
|
||||
// 更新时间
|
||||
@LastModifiedDate
|
||||
private Date updateDate;
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
package com.linln.admin.users.repository;
|
||||
|
||||
import com.linln.admin.users.domain.Configs;
|
||||
import com.linln.modules.system.repository.BaseRepository;
|
||||
|
||||
/**
|
||||
* @author gion
|
||||
* @date 2024/12/17
|
||||
*/
|
||||
public interface ConfigsRepository extends BaseRepository<Configs, Long> {
|
||||
}
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
package com.linln.admin.users.service;
|
||||
|
||||
import com.linln.admin.users.domain.Configs;
|
||||
import com.linln.common.enums.StatusEnum;
|
||||
import org.springframework.data.domain.Example;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author gion
|
||||
* @date 2024/12/17
|
||||
*/
|
||||
public interface ConfigsService {
|
||||
|
||||
/**
|
||||
* 获取分页列表数据
|
||||
* @param example 查询实例
|
||||
* @return 返回分页数据
|
||||
*/
|
||||
Page<Configs> getPageList(Example<Configs> example);
|
||||
|
||||
/**
|
||||
* 根据ID查询数据
|
||||
* @param id 主键ID
|
||||
*/
|
||||
Configs getById(Long id);
|
||||
|
||||
/**
|
||||
* 保存数据
|
||||
* @param configs 实体对象
|
||||
*/
|
||||
Configs save(Configs configs);
|
||||
|
||||
/**
|
||||
* 状态(启用,冻结,删除)/批量状态处理
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
Boolean updateStatus(StatusEnum statusEnum, List<Long> idList);
|
||||
}
|
||||
|
|
@ -0,0 +1,65 @@
|
|||
package com.linln.admin.users.service.impl;
|
||||
|
||||
import com.linln.admin.users.domain.Configs;
|
||||
import com.linln.admin.users.repository.ConfigsRepository;
|
||||
import com.linln.admin.users.service.ConfigsService;
|
||||
import com.linln.common.data.PageSort;
|
||||
import com.linln.common.enums.StatusEnum;
|
||||
import org.springframework.data.domain.Example;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* @author gion
|
||||
* @date 2024/12/17
|
||||
*/
|
||||
@Service
|
||||
public class ConfigsServiceImpl implements ConfigsService {
|
||||
|
||||
@Resource
|
||||
private ConfigsRepository configsRepository;
|
||||
|
||||
/**
|
||||
* 根据ID查询数据
|
||||
* @param id 主键ID
|
||||
*/
|
||||
@Override
|
||||
public Configs getById(Long id) {
|
||||
return configsRepository.findById(id).orElse(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取分页列表数据
|
||||
* @param example 查询实例
|
||||
* @return 返回分页数据
|
||||
*/
|
||||
@Override
|
||||
public Page<Configs> getPageList(Example<Configs> example) {
|
||||
// 创建分页对象
|
||||
PageRequest page = PageSort.pageRequest();
|
||||
return configsRepository.findAll(example, page);
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存数据
|
||||
* @param configs 实体对象
|
||||
*/
|
||||
@Override
|
||||
public Configs save(Configs configs) {
|
||||
return configsRepository.save(configs);
|
||||
}
|
||||
|
||||
/**
|
||||
* 状态(启用,冻结,删除)/批量状态处理
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Boolean updateStatus(StatusEnum statusEnum, List<Long> idList) {
|
||||
return configsRepository.updateStatus(statusEnum.getCode(), idList) > 0;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
package com.linln.admin.users.validator;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
|
||||
/**
|
||||
* @author gion
|
||||
* @date 2024/12/17
|
||||
*/
|
||||
@Data
|
||||
public class ConfigsValid implements Serializable {
|
||||
@NotEmpty(message = "配置名称不能为空")
|
||||
private String name;
|
||||
@NotEmpty(message = "配置类型不能为空")
|
||||
private String configType;
|
||||
}
|
||||
|
|
@ -0,0 +1,59 @@
|
|||
<!DOCTYPE html>
|
||||
<html xmlns:th="http://www.thymeleaf.org">
|
||||
<head th:replace="/common/template :: header(~{::title},~{::link},~{::style})">
|
||||
</head>
|
||||
<body>
|
||||
<div class="layui-form timo-compile">
|
||||
<form th:action="@{/users/configs/save}">
|
||||
<input type="hidden" name="id" th:if="${configs}" th:value="${configs.id}">
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">配置名称</label>
|
||||
<div class="layui-input-inline">
|
||||
<input class="layui-input" type="text" name="name" placeholder="请输入配置名称" th:value="${configs?.name}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">配置类型</label>
|
||||
<div class="layui-input-inline">
|
||||
<input class="layui-input" type="text" name="configType" placeholder="请输入配置类型" th:value="${configs?.configType}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">内容</label>
|
||||
<div class="layui-input-inline">
|
||||
<input class="layui-input" type="text" name="content" placeholder="请输入内容" th:value="${configs?.content}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">排序</label>
|
||||
<div class="layui-input-inline">
|
||||
<input class="layui-input" type="text" name="sort" placeholder="请输入排序" th:value="${configs?.sort}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">内容类型</label>
|
||||
<div class="layui-input-inline">
|
||||
<input class="layui-input" type="text" name="contentType" placeholder="请输入内容类型" th:value="${configs?.contentType}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">跳转类型</label>
|
||||
<div class="layui-input-inline">
|
||||
<input class="layui-input" type="text" name="jumpType" placeholder="请输入跳转类型" th:value="${configs?.jumpType}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">跳转URL</label>
|
||||
<div class="layui-input-inline">
|
||||
<input class="layui-input" type="text" name="jumpUrl" placeholder="请输入跳转URL" th:value="${configs?.jumpUrl}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item timo-finally">
|
||||
<button class="layui-btn ajax-submit"><i class="fa fa-check-circle"></i> 保存</button>
|
||||
<button class="layui-btn btn-secondary close-popup"><i class="fa fa-times-circle"></i> 关闭</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<script th:replace="/common/template :: script"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -0,0 +1,49 @@
|
|||
<!DOCTYPE html>
|
||||
<html xmlns:th="http://www.thymeleaf.org">
|
||||
<head th:replace="/common/template :: header(~{::title},~{::link},~{::style})">
|
||||
</head>
|
||||
<body>
|
||||
<div class="timo-detail-page">
|
||||
<div class="timo-detail-title">基本信息</div>
|
||||
<table class="layui-table timo-detail-table">
|
||||
<colgroup>
|
||||
<col width="100px"><col>
|
||||
<col width="100px"><col>
|
||||
</colgroup>
|
||||
<tbody>
|
||||
<tr>
|
||||
<th>主键ID</th>
|
||||
<td th:text="${configs.id}"></td>
|
||||
<th>配置名称</th>
|
||||
<td th:text="${configs.name}"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>配置类型</th>
|
||||
<td th:text="${configs.configType}"></td>
|
||||
<th>内容</th>
|
||||
<td th:text="${configs.content}"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>排序</th>
|
||||
<td th:text="${configs.sort}"></td>
|
||||
<th>内容类型</th>
|
||||
<td th:text="${configs.contentType}"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>跳转类型</th>
|
||||
<td th:text="${configs.jumpType}"></td>
|
||||
<th>跳转URL</th>
|
||||
<td th:text="${configs.jumpUrl}"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>创建时间</th>
|
||||
<td th:text="${#dates.format(configs.createDate, 'yyyy-MM-dd HH:mm:ss')}"></td>
|
||||
<th>更新时间</th>
|
||||
<td th:text="${#dates.format(configs.updateDate, 'yyyy-MM-dd HH:mm:ss')}"></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<script th:replace="/common/template :: script"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -0,0 +1,91 @@
|
|||
<!DOCTYPE html>
|
||||
<html xmlns:th="http://www.thymeleaf.org"
|
||||
xmlns:mo="http://www.thymeleaf.org">
|
||||
<head th:replace="/common/template :: header(~{::title},~{::link},~{::style})">
|
||||
</head>
|
||||
<body class="timo-layout-page">
|
||||
<div class="layui-card">
|
||||
<div class="layui-card-header timo-card-header">
|
||||
<span><i class="fa fa-bars"></i> systemConfig管理</span>
|
||||
<i class="layui-icon layui-icon-refresh refresh-btn"></i>
|
||||
</div>
|
||||
<div class="layui-card-body">
|
||||
<div class="layui-row timo-card-screen">
|
||||
<div class="pull-left layui-form-pane timo-search-box">
|
||||
<div class="layui-inline">
|
||||
<label class="layui-form-label">状态</label>
|
||||
<div class="layui-input-block timo-search-status">
|
||||
<select class="timo-search-select" name="status" mo:dict="SEARCH_STATUS" mo-selected="${param.status}"></select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-inline">
|
||||
<label class="layui-form-label">配置名称</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="name" th:value="${param.name}" placeholder="请输入配置名称" autocomplete="off" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-inline">
|
||||
<button class="layui-btn timo-search-btn">
|
||||
<i class="fa fa-search"></i>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="pull-right screen-btn-group">
|
||||
<button class="layui-btn open-popup" data-title="添加systemConfig" th:attr="data-url=@{/users/configs/add}" data-size="auto">
|
||||
<i class="fa fa-plus"></i> 添加</button>
|
||||
<div class="btn-group">
|
||||
<button class="layui-btn">操作<span class="caret"></span></button>
|
||||
<dl class="layui-nav-child layui-anim layui-anim-upbit">
|
||||
<dd><a class="ajax-status" th:href="@{/users/configs/status/ok}">启用</a></dd>
|
||||
<dd><a class="ajax-status" th:href="@{/users/configs/status/freezed}">冻结</a></dd>
|
||||
<dd><a class="ajax-status" th:href="@{/users/configs/status/delete}">删除</a></dd>
|
||||
</dl>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="timo-table-wrap">
|
||||
<table class="layui-table timo-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="timo-table-checkbox">
|
||||
<label class="timo-checkbox"><input type="checkbox">
|
||||
<i class="layui-icon layui-icon-ok"></i></label>
|
||||
</th>
|
||||
<th>主键ID</th>
|
||||
<th>配置名称</th>
|
||||
<th>配置类型</th>
|
||||
<th>内容</th>
|
||||
<th>排序</th>
|
||||
<th>内容类型</th>
|
||||
<th>跳转类型</th>
|
||||
<th>跳转URL</th>
|
||||
<th>操作</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr th:each="item:${list}">
|
||||
<td><label class="timo-checkbox"><input type="checkbox" th:value="${item.id}">
|
||||
<i class="layui-icon layui-icon-ok"></i></label></td>
|
||||
<td th:text="${item.id}">主键ID</td>
|
||||
<td th:text="${item.name}">配置名称</td>
|
||||
<td th:text="${item.configType}">配置类型</td>
|
||||
<td th:text="${item.content}">内容</td>
|
||||
<td th:text="${item.sort}">排序</td>
|
||||
<td th:text="${item.contentType}">内容类型</td>
|
||||
<td th:text="${item.jumpType}">跳转类型</td>
|
||||
<td th:text="${item.jumpUrl}">跳转URL</td>
|
||||
<td>
|
||||
<a class="open-popup" data-title="编辑systemConfig" th:attr="data-url=@{'/users/configs/edit/'+${item.id}}" data-size="auto" href="#">编辑</a>
|
||||
<a class="open-popup" data-title="详细信息" th:attr="data-url=@{'/users/configs/detail/'+${item.id}}" data-size="800,600" href="#">详细</a>
|
||||
<a class="ajax-get" data-msg="您是否确认删除" th:href="@{/users/configs/status/delete(ids=${item.id})}">删除</a>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div th:replace="/common/fragment :: page"></div>
|
||||
</div>
|
||||
</div>
|
||||
<script th:replace="/common/template :: script"></script>
|
||||
</body>
|
||||
</html>
|
||||
Loading…
Reference in New Issue