Commit da3320f2 authored by 廖旭伟's avatar 廖旭伟

增加前台登录接口,前台查询作品接口

parent fa057b85
......@@ -1443,7 +1443,7 @@ msg|String|消息|-
```
## 客户作品信息
### 查询客户作品信息列表
### 客户查询自己作品信息列表
**请求URL:** customer/work/design/list
......@@ -1482,9 +1482,15 @@ data|object|数据对象
 data|array|结果集列表|数组
  id|Long|主键ID,主键,自增长
  customerId|Long|客户ID
  createTime|Date|收藏时间
  masterplateId|Long|模版ID
dict|object|字典对象
  createTime|Date|创建时间
  workDesignName|String|作品名称
  workDesignStatus|Integer|作品状态:0:草稿,1:发布
  workDesignDesc|String|作品描述
  updateTime|Date|更新时间
  pictureIds|String|模版引用的图片
  pictureSrcIds|String|模版引用的素材
  pictureBackgroundIds|String|模版引用的背景
  fontIds|String|作品引用的字体
**响应消息样例:**
```
......@@ -1495,6 +1501,86 @@ dict|object|字典对象
}
```
### 管理查询客户作品信息列表
**请求URL:** customer/work/design/picture/list
**请求方式:** POST
**内容类型:** application/json;charset=utf-8
**简要描述:** 查询客户作品信息
**请求参数:**
参数名称|类型|必填|描述
:---|:---|:---|:------
customerId|Long|是|客户id
**请求样例:**
```
{
"customerId":1
}
```
**响应参数:**
参数名称|参数类型|描述
:---|:---|:------
code|Integer|结果码(-1.失败,1.成功)
msg|String|消息
data|object|数据对象
 per_page|Integer|每页条数
 total|Integer|总条数
 last_page|Integer|总页数
 current_page|Integer|当前页
 data|array|结果集列表|数组
  id|Long|主键ID,主键,自增长
  customerId|Long|客户ID
  createTime|Date|创建时间
  workDesignName|String|作品名称
  workDesignStatus|Integer|作品状态:0:草稿,1:发布
  workDesignDesc|String|作品描述
  updateTime|Date|更新时间
  pictureIds|String|模版引用的图片
  pictureSrcIds|String|模版引用的素材
  pictureBackgroundIds|String|模版引用的背景
  fontIds|String|作品引用的字体
**响应消息样例:**
```
{
"code": 1,
"data": {
"data": [
{
"createTime": 1655447457000,
"createTimeStr": "2022-06-17 14:30:57",
"customerId": 1,
"deleted": 0,
"fontIds": "1",
"id": 1,
"pictureBackgroundIds": "1",
"pictureIds": "1",
"pictureSrcIds": "1",
"updateTime": 1655447477000,
"updateTimeStr": "2022-06-17 14:31:17",
"workDesignDesc": "随便写",
"workDesignName": "测试",
"workDesignStatus": 1
}
]
},
"dict": {
"workDesignStatus": {
"1": "草稿",
"2": "发布"
}
}
}
```
### 查看客户作品信息
**请求URL:** customer/work/design/info
......@@ -1524,8 +1610,15 @@ msg|String|消息
data|object|数据对象
 id|Long|主键ID,主键,自增长
 customerId|Long|客户ID
 createTime|Date|收藏时间
 masterplateId|Long|模版ID
 createTime|Date|创建时间
 workDesignName|String|作品名称
 workDesignStatus|Integer|作品状态:0:草稿,1:发布
 workDesignDesc|String|作品描述
 updateTime|Date|更新时间
 pictureIds|String|模版引用的图片
 pictureSrcIds|String|模版引用的素材
 pictureBackgroundIds|String|模版引用的背景
 fontIds|String|作品引用的字体
dict|object|字典对象
**响应消息样例:**
......@@ -1533,10 +1626,17 @@ dict|object|字典对象
{
"code": 1,
"data": {
"id":2739,
"customerId":7423,
"createTime":"2022-06-07",
"masterplateId":4628
"id":9033,
"customerId":9079,
"createTime":"2022-06-15",
"workDesignName":"wxj0ji",
"workDesignStatus":4279,
"workDesignDesc":"yxwojz",
"updateTime":"2022-06-15",
"pictureIds":"4cqqam",
"pictureSrcIds":"jwtdgo",
"pictureBackgroundIds":"ndmkiz",
"fontIds":"3m5zxj"
}
}
```
......@@ -1556,13 +1656,25 @@ dict|object|字典对象
参数名称|类型|必填|描述
:---|:---|:---|:-------
customerId|Long|是|客户ID
masterplateId|Long|是|模版ID
workDesignName|String|是|作品名称
workDesignStatus|Integer|是|作品状态:0:草稿,1:发布
workDesignDesc|String|是|作品描述
pictureIds|String|是|模版引用的图片
pictureSrcIds|String|是|模版引用的素材
pictureBackgroundIds|String|是|模版引用的背景
fontIds|String|是|作品引用的字体
**请求样例:**
```
{
"customerId":2890,
"masterplateId":6167
"customerId":6797,
"workDesignName":"c42lp8",
"workDesignStatus":3570,
"workDesignDesc":"g3odxd",
"pictureIds":"3fd0o6",
"pictureSrcIds":"ykn50w",
"pictureBackgroundIds":"ad0eh7",
"fontIds":"f3bacv"
}
```
......@@ -1577,8 +1689,15 @@ data|object|数据对象
 entity|object|保存更新实体
  id|Long|主键ID,主键,自增长
  customerId|Long|客户ID
  createTime|Date|收藏时间
  masterplateId|Long|模版ID
  createTime|Date|创建时间
  workDesignName|String|作品名称
  workDesignStatus|Integer|作品状态:0:草稿,1:发布
  workDesignDesc|String|作品描述
  updateTime|Date|更新时间
  pictureIds|String|模版引用的图片
  pictureSrcIds|String|模版引用的素材
  pictureBackgroundIds|String|模版引用的背景
  fontIds|String|作品引用的字体
**响应消息样例:**
```
......
......@@ -7,6 +7,7 @@ import com.mortals.framework.util.AESUtil;
import com.mortals.framework.utils.ServletUtils;
import com.mortals.framework.web.interceptor.BaseInterceptor;
import com.mortals.xhx.base.framework.config.InterceptorConfig;
import com.mortals.xhx.common.key.Constant;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.ObjectUtils;
......@@ -51,7 +52,7 @@ public class AuthUserInterceptor extends BaseInterceptor {
ret.put("msg", "用户未登录或登录失效,请重新登录");
ServletUtils.renderString(response, JSONObject.toJSONString(ret));
return false;
}else if(loginUser.isAdmin()||loginUser.getUserType()==1){
}else if(loginUser.isAdmin()||loginUser.getUserType()==1||loginUser.getUserType()== Constant.CUSTOMER_USER){
return super.preHandle(request, response, handler);
} else {
ret.put("code", -1);
......
package com.mortals.xhx.base.login.web;
import cn.hutool.core.util.IdUtil;
import com.alibaba.fastjson.JSONObject;
import com.mortals.framework.service.IAuthTokenService;
import com.mortals.framework.util.DateUtils;
import com.mortals.framework.util.StringUtils;
import com.mortals.framework.web.BaseCRUDJsonBodyMappingController;
import com.mortals.xhx.module.customer.model.CustomerEntity;
import com.mortals.xhx.module.customer.service.CustomerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.HashMap;
import java.util.Map;
@RestController
@RequestMapping("customer/login")
public class CustomerLoginController extends BaseCRUDJsonBodyMappingController<CustomerService, CustomerEntity, Long> {
@Autowired
private CustomerService customerService;
@Autowired
private IAuthTokenService authTokenService;
@RequestMapping("login")
public String login(@RequestBody LoginForm loginForm) throws Exception {
JSONObject ret = new JSONObject();
Map<String, Object> data = new HashMap<>();
String loginName = loginForm.getLoginName();
String password = loginForm.getPassword();
String ip = super.getRequestIP(request);
if (StringUtils.isEmpty(loginName) || StringUtils.isEmpty(password)) {
ret.put(KEY_RESULT_CODE, VALUE_RESULT_FAILURE);
ret.put(KEY_RESULT_MSG, "未获取到用户信息,请重新登录");
return ret.toJSONString();
}
CustomerEntity customerEntity = null;
try {
loginForm.validate();
customerEntity = customerService.doLogin(loginName, password, ip);
customerEntity.setLastLoginAddress(ip);
customerEntity.setLoginTime(System.currentTimeMillis());
customerEntity.setToken(IdUtil.fastSimpleUUID());
customerEntity.setExpireTime(DateUtils.addCurrDate(7).getTime());
String token = authTokenService.createToken(customerEntity);
data.put("token", token);
data.put("customer", customerEntity);
recordSysLog(request, customerEntity, "客户登录系统成功!");
ret.put(KEY_RESULT_DATA, data);
ret.put(KEY_RESULT_CODE, VALUE_RESULT_SUCCESS);
ret.put(KEY_RESULT_MSG, "用户登录系统成功!");
return ret.toJSONString();
} catch (Exception e) {
log.error("login error ", e);
ret.put(KEY_RESULT_CODE, VALUE_RESULT_FAILURE);
ret.put(KEY_RESULT_MSG, super.convertException(e));
return ret.toJSONString();
}
}
@RequestMapping("logout")
public void logout() throws Exception {
recordSysLog(request, "退出登录");
super.removeCurrUser(request);
}
}
package com.mortals.xhx.base.login.web;
import cn.hutool.core.util.IdUtil;
import com.alibaba.fastjson.JSONObject;
import com.mortals.framework.ap.GlobalSysInfo;
import com.mortals.framework.ap.SysConstains;
......@@ -77,7 +78,8 @@ public class LoginController extends BaseCRUDJsonBodyMappingController<UserServi
if (currUserName == null || currUserName.trim().length() == 0) {
currUserName = "管理员";
}
userEntity.setLoginTime(System.currentTimeMillis());
userEntity.setToken(IdUtil.fastSimpleUUID());
userEntity.setExpireTime(DateUtils.addCurrDate(7).getTime());
String token = authTokenService.createToken(userEntity);
JSONObject data = new JSONObject();
......
......@@ -307,25 +307,6 @@ public class UserEntity extends UserEntityExt implements IUser {
return this.userType;
}
@Override
public String getToken() {
return null;
}
@Override
public Long getLoginTime() {
return null;
}
@Override
public Long getExpireTime() {
return null;
}
@Override
public void setExpireTime(Long expireTime) {
}
@Override
public String getMenuUrl() {
......
package com.mortals.xhx.base.system.user.model;
import com.alibaba.fastjson.annotation.JSONField;
import com.mortals.framework.model.BaseEntityLong;
import lombok.Data;
......@@ -12,6 +13,22 @@ import java.util.List;
*/
@Data
public class UserEntityExt extends BaseEntityLong {
/**
* 唯一标识
*/
@JSONField(serialize = false)
private String token;
/**
* 登录时间
*/
private Long loginTime;
/**
* 过期时间
*/
private Long expireTime;
private String siteName;
private List<Long> roleIds;
private String siteCode;
......
......@@ -30,4 +30,7 @@ public final class Constant {
public final static String Param_sealWay = "sealWay";
public final static String Param_typeOptions = "typeOptions";
/** 登录用户类型为客户 */
public final static int CUSTOMER_USER = 99;
}
......@@ -8,6 +8,8 @@ import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.mortals.framework.annotation.Excel;
import com.mortals.framework.model.BaseEntityLong;
import com.mortals.framework.service.IUser;
import com.mortals.xhx.common.key.Constant;
import com.mortals.xhx.module.customer.model.vo.CustomerVo;
/**
* 客户管理实体对象
......@@ -16,7 +18,7 @@ import com.mortals.xhx.module.customer.model.vo.CustomerVo;
* @date 2022-06-13
*/
public class CustomerEntity extends CustomerVo {
public class CustomerEntity extends CustomerVo implements IUser {
private static final long serialVersionUID = 1L;
/**
......@@ -88,6 +90,7 @@ public class CustomerEntity extends CustomerVo {
* 获取 用户登录账号
* @return String
*/
@Override
public String getLoginName(){
return loginName;
}
......@@ -366,4 +369,67 @@ public class CustomerEntity extends CustomerVo {
this.lastLoginAddress = "";
}
@Override
public Long getDeptId() {
return null;
}
@Override
public String getDeptName() {
return null;
}
@Override
public Long getCustomerId() {
return null;
}
@Override
public String getSiteIds() {
return null;
}
@Override
public Long getCustomerJoinId() {
return null;
}
@Override
public String getCustomerNum() {
return null;
}
@Override
public String getRealName() {
return this.custName;
}
@Override
public boolean isAdmin() {
return false;
}
@Override
public boolean isSystemUser() {
return false;
}
@Override
public boolean isManager() {
return false;
}
@Override
public Integer getUserType() {
return Constant.CUSTOMER_USER;
}
@Override
public String getMenuUrl() {
return null;
}
}
\ No newline at end of file
package com.mortals.xhx.module.customer.model.vo;
import com.alibaba.fastjson.annotation.JSONField;
import com.mortals.framework.model.BaseEntityLong;
import com.mortals.xhx.module.customer.model.CustomerEntity;
import lombok.Data;
......@@ -14,6 +15,22 @@ import java.util.List;
@Data
public class CustomerVo extends BaseEntityLong {
/**
* 唯一标识
*/
@JSONField(serialize = false)
private String token;
/**
* 登录时间
*/
private Long loginTime;
/**
* 过期时间
*/
private Long expireTime;
/** 查询条件 */
private String query;
/** 站点编码 */
......
......@@ -16,4 +16,5 @@ import java.util.List;
public class CustomerWorkDesignVo extends BaseEntityLong {
private String createTimeStr;
private String updateTimeStr;
}
\ No newline at end of file
......@@ -20,4 +20,14 @@ public interface CustomerService extends ICRUDService<CustomerEntity,Long>{
Result<CustomerEntityExt> findExt(CustomerEntity params, PageInfo pageInfo, Context context) throws AppException;
/**
* 客户登录
* @param loginName
* @param password
* @param loginIp
* @return
* @throws AppException
*/
CustomerEntity doLogin(String loginName, String password, String loginIp) throws AppException;
}
\ No newline at end of file
......@@ -4,6 +4,7 @@ import com.mortals.framework.model.Context;
import com.mortals.framework.model.PageInfo;
import com.mortals.framework.model.Result;
import com.mortals.framework.util.DateUtils;
import com.mortals.framework.util.SecurityUtil;
import com.mortals.framework.util.StringUtils;
import com.mortals.xhx.module.customer.model.CustomerEntityExt;
import com.mortals.xhx.module.customer.model.CustomerQuery;
......@@ -28,6 +29,20 @@ import java.util.List;
@Service("customerService")
public class CustomerServiceImpl extends AbstractCRUDServiceImpl<CustomerDao, CustomerEntity, Long> implements CustomerService {
@Override
protected void saveBefore(CustomerEntity entity, Context context) throws AppException {
this.validData(entity, context);
if (StringUtils.isNotEmpty(entity.getPassword())) {
try {
entity.setPassword(SecurityUtil.md5DoubleEncoding(entity.getPassword()));
} catch (Exception e) {
throw new AppException("密码转换异常");
}
} else {
entity.setPassword(null);
}
}
@Override
protected CustomerEntity findBefore(CustomerEntity entity, PageInfo pageInfo, Context context) throws AppException {
CustomerQuery query = new CustomerQuery();
......@@ -62,4 +77,27 @@ public class CustomerServiceImpl extends AbstractCRUDServiceImpl<CustomerDao, Cu
}
return result;
}
@Override
public CustomerEntity doLogin(String loginName, String password, String loginIp) throws AppException {
CustomerEntity user = this.findByLoginName(loginName);
if (user == null || !user.getLoginName().equals(loginName)) {
throw new AppException("用户名不存在!");
}
try {
if (!user.getPassword().equals(SecurityUtil.md5DoubleEncoding(password))) {
throw new AppException("登录密码错误!");
}
} catch (Exception e) {
throw new AppException("密码验认出错!", e);
}
return user;
}
private CustomerEntity findByLoginName(String loginName) {
CustomerEntity params = new CustomerEntity();
params.setLoginName(loginName);
return this.selectOne(params);
}
}
\ No newline at end of file
......@@ -24,4 +24,10 @@ public class CustomerWorkCollectServiceImpl extends AbstractCRUDServiceImpl<Cust
return super.findBefore(params, pageInfo, context);
}
@Override
protected void saveBefore(CustomerWorkCollectEntity entity, Context context) throws AppException {
this.validData(entity, context);
entity.setCustomerId(this.getContextUserId(context));
}
}
\ No newline at end of file
......@@ -2,6 +2,7 @@ package com.mortals.xhx.module.customer.service.impl;
import com.mortals.framework.exception.AppException;
import com.mortals.framework.model.Context;
import com.mortals.framework.model.PageInfo;
import com.mortals.xhx.module.customer.model.CustomerWorkCollectEntity;
import org.springframework.stereotype.Service;
import com.mortals.framework.service.impl.AbstractCRUDServiceImpl;
import com.mortals.xhx.module.customer.dao.CustomerWorkDesignDao;
......@@ -23,4 +24,10 @@ public class CustomerWorkDesignServiceImpl extends AbstractCRUDServiceImpl<Custo
return super.findBefore(params, pageInfo, context);
}
@Override
protected void saveBefore(CustomerWorkDesignEntity entity, Context context) throws AppException {
this.validData(entity, context);
entity.setCustomerId(this.getContextUserId(context));
}
}
\ No newline at end of file
package com.mortals.xhx.module.customer.service.impl;
import com.mortals.framework.exception.AppException;
import com.mortals.framework.model.Context;
import com.mortals.xhx.module.customer.model.CustomerWorkDesignEntity;
import org.springframework.stereotype.Service;
import com.mortals.framework.service.impl.AbstractCRUDServiceImpl;
import com.mortals.xhx.module.customer.dao.CustomerWorkDesignStatDao;
......@@ -14,4 +17,9 @@ import com.mortals.xhx.module.customer.service.CustomerWorkDesignStatService;
@Service("customerWorkDesignStatService")
public class CustomerWorkDesignStatServiceImpl extends AbstractCRUDServiceImpl<CustomerWorkDesignStatDao, CustomerWorkDesignStatEntity, Long> implements CustomerWorkDesignStatService {
@Override
protected void saveBefore(CustomerWorkDesignStatEntity entity, Context context) throws AppException {
this.validData(entity, context);
entity.setCustomerId(this.getContextUserId(context));
}
}
\ No newline at end of file
......@@ -2,6 +2,7 @@ package com.mortals.xhx.module.customer.web;
import com.alibaba.fastjson.JSONObject;
import com.mortals.framework.common.IBaseEnum;
import com.mortals.framework.exception.AppException;
import com.mortals.framework.model.Context;
import com.mortals.framework.model.PageInfo;
import com.mortals.framework.model.Result;
......@@ -139,4 +140,16 @@ public class CustomerController extends BaseCRUDJsonBodyMappingController<Custom
return ret.toJSONString();
}
}
@Override
protected int editAfter(Long id, Map<String, Object> model, CustomerEntity entity, Context context) throws AppException {
entity.setPassword(null);
return 1;
}
@Override
protected int viewAfter(Long id, Map<String, Object> model, CustomerEntity entity, Context context) throws AppException {
entity.setPassword(null);
return 1;
}
}
\ No newline at end of file
package com.mortals.xhx.module.customer.web;
import com.mortals.framework.exception.AppException;
import com.mortals.framework.web.BaseCRUDJsonBodyMappingController;
import com.mortals.xhx.base.system.param.service.ParamService;
import com.mortals.xhx.common.key.Constant;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
......@@ -46,5 +48,12 @@ public class CustomerWorkCollectController extends BaseCRUDJsonBodyMappingContro
super.init(model, context);
}
@Override
protected void doListBefore(CustomerWorkCollectEntity query, Map<String, Object> model, Context context) throws AppException {
if(this.getCurUser()==null||this.getCurUser().getUserType()!= Constant.CUSTOMER_USER){
throw new AppException("非法用户,不可访问");
}
query.setCustomerId(this.getCurUser().getId());
}
}
\ No newline at end of file
package com.mortals.xhx.module.customer.web;
import com.alibaba.fastjson.JSONObject;
import com.mortals.framework.annotation.UnAuth;
import com.mortals.framework.common.IBaseEnum;
import com.mortals.framework.exception.AppException;
import com.mortals.framework.model.Context;
import com.mortals.framework.model.PageInfo;
import com.mortals.framework.model.Result;
import com.mortals.framework.util.DateUtils;
import com.mortals.framework.web.BaseCRUDJsonBodyMappingController;
import com.mortals.xhx.base.system.param.service.ParamService;
import com.mortals.xhx.common.code.MemberLevelEnum;
import com.mortals.xhx.common.code.WorkDesignStatusEnum;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import com.mortals.framework.model.Context;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.mortals.framework.web.BaseCRUDJsonBodyMappingController;
import com.mortals.xhx.common.key.Constant;
import com.mortals.xhx.module.customer.model.CustomerWorkDesignEntity;
import com.mortals.xhx.module.customer.model.CustomerWorkDesignQuery;
import com.mortals.xhx.module.customer.service.CustomerWorkDesignService;
import org.apache.commons.lang3.ArrayUtils;
import com.mortals.framework.util.StringUtils;
import java.util.*;
import java.util.stream.Collectors;
import com.alibaba.fastjson.JSONObject;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import static com.mortals.framework.ap.SysConstains.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
*
* 客户作品信息
......@@ -56,6 +49,7 @@ public class CustomerWorkDesignController extends BaseCRUDJsonBodyMappingControl
if(CollectionUtils.isNotEmpty(resultList)){
resultList.stream().forEach(item->{
item.setCreateTimeStr(DateUtils.getDateTimeStr(item.getCreateTime(),DateUtils.P_yyyy_MM_dd_HH_mm_ss));
item.setUpdateTimeStr(DateUtils.getDateTimeStr(item.getUpdateTime(),DateUtils.P_yyyy_MM_dd_HH_mm_ss));
if(item.getWorkDesignStatus()==WorkDesignStatusEnum.DRAFT.getValue()){
draft.add(item);
}else {
......@@ -69,4 +63,48 @@ public class CustomerWorkDesignController extends BaseCRUDJsonBodyMappingControl
model.put("data",map);
return 1;
}
@Override
protected void doListBefore(CustomerWorkDesignEntity query, Map<String, Object> model, Context context) throws AppException {
if(this.getCurUser()==null||this.getCurUser().getUserType()!= Constant.CUSTOMER_USER){
throw new AppException("非法用户,不可访问");
}
query.setCustomerId(this.getCurUser().getId());
}
@PostMapping({"picture/list"})
@UnAuth
public String pictureList(@RequestBody CustomerWorkDesignEntity query) {
Map<String, Object> model = new HashMap();
JSONObject ret = new JSONObject();
Context context = this.getContext();
String busiDesc = "查询" + this.getModuleDesc();
int code;
try {
if(query.getCustomerId()==null){
throw new AppException("客户id不能为空");
}
List<CustomerWorkDesignEntity> result = this.getService().find(query, context);
if(CollectionUtils.isNotEmpty(result)){
result.stream().forEach(item->{
item.setCreateTimeStr(DateUtils.getDateTimeStr(item.getCreateTime(),DateUtils.P_yyyy_MM_dd_HH_mm_ss));
item.setUpdateTimeStr(DateUtils.getDateTimeStr(item.getUpdateTime(),DateUtils.P_yyyy_MM_dd_HH_mm_ss));
});
}
model.put("data", result);
code = 1;
this.recordSysLog(this.request, busiDesc + " 【成功】");
} catch (Exception var9) {
code = -1;
this.doException(this.request, busiDesc, model, var9);
}
this.init(model, context);
ret.put("code", code);
ret.put("msg", model.remove("message_info"));
ret.put("dict", model.remove("dict"));
ret.put("data", model);
return ret.toJSONString();
}
}
\ No newline at end of file
package com.mortals.xhx.module.customer.web;
import com.mortals.framework.exception.AppException;
import com.mortals.framework.web.BaseCRUDJsonBodyMappingController;
import com.mortals.xhx.base.system.param.service.ParamService;
import com.mortals.xhx.common.key.Constant;
import com.mortals.xhx.module.customer.model.CustomerWorkCollectEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
......@@ -46,5 +49,11 @@ public class CustomerWorkDesignStatController extends BaseCRUDJsonBodyMappingCon
super.init(model, context);
}
@Override
protected void doListBefore(CustomerWorkDesignStatEntity query, Map<String, Object> model, Context context) throws AppException {
if(this.getCurUser()==null||this.getCurUser().getUserType()!= Constant.CUSTOMER_USER){
throw new AppException("非法用户,不可访问");
}
query.setCustomerId(this.getCurUser().getId());
}
}
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"mybatis-3-mapper.dtd">
<mapper namespace="com.mortals.xhx.module.customer.dao.ibatis.CustomerWorkCollectDaoImpl">
<!-- 字段和属性映射 -->
<resultMap type="CustomerWorkCollectEntity" id="CustomerWorkCollectEntity-Map">
<id property="id" column="id" />
<result property="customerId" column="customerId" />
<result property="masterplateId" column="masterplateId" />
<result property="createTime" column="createTime" />
</resultMap>
<!-- 表所有列 -->
<sql id="_columns">
<trim suffixOverrides="," suffix="">
<if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('id') or colPickMode == 1 and data.containsKey('id')))">
a.id,
</if>
<if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('customerId') or colPickMode == 1 and data.containsKey('customerId')))">
a.customerId,
</if>
<if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('masterplateId') or colPickMode == 1 and data.containsKey('masterplateId')))">
a.masterplateId,
</if>
<if test="(data == null) or (data != null and ( colPickMode == 0 and !data.containsKey('createTime') or colPickMode == 1 and data.containsKey('createTime')))">
a.createTime,
</if>
</trim>
</sql>
<!-- 新增 区分主键自增加还是业务插入 -->
<insert id="insert" parameterType="CustomerWorkCollectEntity" useGeneratedKeys="true" keyProperty="id">
insert into mortals_xhx_customer_work_collect
(customerId,masterplateId,createTime)
VALUES
(#{customerId},#{masterplateId},#{createTime})
</insert>
<!-- 批量新增 -->
<insert id="insertBatch" parameterType="paramDto">
insert into mortals_xhx_customer_work_collect
(customerId,masterplateId,createTime)
VALUES
<foreach collection="data.dataList" item="item" index="index" separator="," >
(#{item.customerId},#{item.masterplateId},#{item.createTime})
</foreach>
</insert>
<!-- 根据ParamDto更新 -->
<update id="update" parameterType="paramDto">
update mortals_xhx_customer_work_collect as a
set
<trim suffixOverrides="," suffix="">
<if test="(colPickMode==0 and data.containsKey('customerId')) or (colPickMode==1 and !data.containsKey('customerId'))">
a.customerId=#{data.customerId},
</if>
<if test="(colPickMode==0 and data.containsKey('customerIdIncrement')) or (colPickMode==1 and !data.containsKey('customerIdIncrement'))">
a.customerId=ifnull(a.customerId,0) + #{data.customerIdIncrement},
</if>
<if test="(colPickMode==0 and data.containsKey('masterplateId')) or (colPickMode==1 and !data.containsKey('masterplateId'))">
a.masterplateId=#{data.masterplateId},
</if>
<if test="(colPickMode==0 and data.containsKey('masterplateIdIncrement')) or (colPickMode==1 and !data.containsKey('masterplateIdIncrement'))">
a.masterplateId=ifnull(a.masterplateId,0) + #{data.masterplateIdIncrement},
</if>
<if test="(colPickMode==0 and data.containsKey('createTime')) or (colPickMode==1 and !data.containsKey('createTime'))">
a.createTime=#{data.createTime},
</if>
</trim>
<trim suffixOverrides="where" suffix="">
where
<trim prefixOverrides="and" prefix="">
<include refid="_condition_"/>
</trim>
</trim>
</update>
<!-- 批量更新 -->
<update id="updateBatch" parameterType="paramDto">
update mortals_xhx_customer_work_collect as a
<trim prefix="set" suffixOverrides=",">
<trim prefix="customerId=(case" suffix="ELSE customerId end),">
<foreach collection="data.dataList" item="item" index="index" separator="" >
<choose>
<when test="(colPickMode==0 and item.containsKey('customerId')) or (colPickMode==1 and !item.containsKey('customerId'))">
when a.id=#{item.id} then #{item.customerId}
</when>
<when test="(colPickMode==0 and item.containsKey('customerIdIncrement')) or (colPickMode==1 and !item.containsKey('customerIdIncrement'))">
when a.id=#{item.id} then ifnull(a.customerId,0) + #{item.customerIdIncrement}
</when>
</choose>
</foreach>
</trim>
<trim prefix="masterplateId=(case" suffix="ELSE masterplateId end),">
<foreach collection="data.dataList" item="item" index="index" separator="" >
<choose>
<when test="(colPickMode==0 and item.containsKey('masterplateId')) or (colPickMode==1 and !item.containsKey('masterplateId'))">
when a.id=#{item.id} then #{item.masterplateId}
</when>
<when test="(colPickMode==0 and item.containsKey('masterplateIdIncrement')) or (colPickMode==1 and !item.containsKey('masterplateIdIncrement'))">
when a.id=#{item.id} then ifnull(a.masterplateId,0) + #{item.masterplateIdIncrement}
</when>
</choose>
</foreach>
</trim>
<trim prefix="createTime=(case" suffix="ELSE createTime end),">
<foreach collection="data.dataList" item="item" index="index" separator="" >
<if test="(colPickMode==0 and item.containsKey('createTime')) or (colPickMode==1 and !item.containsKey('createTime'))">
when a.id=#{item.id} then #{item.createTime}
</if>
</foreach>
</trim>
</trim>
where id in
<foreach collection="data.dataList" item="item" index="index" open="(" separator="," close=")">
#{item.id}
</foreach>
</update>
<!-- 根据主健查询 -->
<select id="getByKey" parameterType="paramDto" resultMap="CustomerWorkCollectEntity-Map">
select <include refid="_columns"/>
from mortals_xhx_customer_work_collect as a
where a.id=#{condition.id}
</select>
<!-- 根据主健删除 -->
<delete id="deleteByKey" parameterType="paramDto">
delete a.* from mortals_xhx_customer_work_collect as a where a.id=#{condition.id}
</delete>
<!-- 根据主健删除一批,针对单一主健有效 -->
<delete id="deleteByKeys">
delete from mortals_xhx_customer_work_collect where id in
<foreach collection="array" item="item" index="index" open="(" separator="," close=")">
#{item}
</foreach>
</delete>
<!-- 根据paramDto删除一批 -->
<delete id="deleteByMap" parameterType="paramDto">
delete a.* from mortals_xhx_customer_work_collect as a
<trim suffixOverrides="where" suffix="">
where
<trim prefixOverrides="and" prefix="">
<include refid="_condition_"/>
</trim>
</trim>
</delete>
<!-- 获取列表 -->
<select id="getList" parameterType="paramDto" resultMap="CustomerWorkCollectEntity-Map">
select <include refid="_columns"/>
from mortals_xhx_customer_work_collect as a
<trim suffixOverrides="where" suffix="">
where
<trim prefixOverrides="and" prefix="">
<include refid="_condition_"/>
</trim>
</trim>
<include refid="_orderCols_"/>
</select>
<!-- 获取 -->
<select id="getListCount" parameterType="paramDto" resultType="int">
select count(1)
from mortals_xhx_customer_work_collect as a
<trim suffixOverrides="where" suffix="">
where
<trim prefixOverrides="and" prefix="">
<include refid="_condition_"/>
</trim>
</trim>
</select>
<!-- 条件映射 -->
<sql id="_condition_">
<if test="condition != null and !condition.isEmpty()">
<!-- 条件映射-普通条件 -->
<include refid="_condition_param_">
<property name="_conditionParam_" value="condition"/>
<property name="_conditionType_" value="and"/>
</include>
<!-- 条件映射-集合之间使用AND,集合中元素使用OR-(list[0].1 or list[0].2) and (list[1].3 or list[1].4) -->
<if test="condition.containsKey('andConditionList') and !condition.andConditionList.isEmpty()">
and
<foreach collection="condition.andConditionList" open="(" close=")" index="index" item="andCondition" separator=" and ">
<trim prefixOverrides="or" prefix="(" suffix=")">
<include refid="_condition_param_">
<property name="_conditionParam_" value="andCondition"/>
<property name="_conditionType_" value="or"/>
</include>
</trim>
</foreach>
</if>
<!-- 条件映射-集合之间使用OR,集合中元素使用AND-(list[0].1 and list[0].2) or (list[1].3 and list[1].4) -->
<if test="condition.containsKey('orConditionList') and !condition.orConditionList.isEmpty()">
and
<foreach collection="condition.orConditionList" open="(" close=")" index="index" item="orCondition" separator=" or ">
<trim prefixOverrides="and" prefix="(" suffix=")">
<include refid="_condition_param_">
<property name="_conditionParam_" value="orCondition"/>
<property name="_conditionType_" value="and"/>
</include>
</trim>
</foreach>
</if>
</if>
</sql>
<!-- 条件映射-代参数 -->
<sql id="_condition_param_">
<bind name="conditionParamRef" value="${_conditionParam_}"/>
<if test="conditionParamRef.containsKey('id')">
<if test="conditionParamRef.id != null">
${_conditionType_} a.id=#{${_conditionParam_}.id}
</if>
</if>
<if test="conditionParamRef.containsKey('id')">
<if test="conditionParamRef.id != null ">
${_conditionType_} a.id = #{${_conditionParam_}.id}
</if>
<if test="conditionParamRef.id == null">
${_conditionType_} a.id is null
</if>
</if>
<if test="conditionParamRef.containsKey('idList')">
${_conditionType_} a.id in
<foreach collection="conditionParamRef.idList" open="(" close=")" index="index" item="item" separator=",">
#{item}
</foreach>
</if>
<if test="conditionParamRef.containsKey('idStart') and conditionParamRef.idStart != null">
${_conditionType_} a.id <![CDATA[ >= ]]> #{${_conditionParam_}.idStart}
</if>
<if test="conditionParamRef.containsKey('idEnd') and conditionParamRef.idEnd != null">
${_conditionType_} a.id <![CDATA[ <= ]]> #{${_conditionParam_}.idEnd}
</if>
<if test="conditionParamRef.containsKey('customerId')">
<if test="conditionParamRef.customerId != null ">
${_conditionType_} a.customerId = #{${_conditionParam_}.customerId}
</if>
<if test="conditionParamRef.customerId == null">
${_conditionType_} a.customerId is null
</if>
</if>
<if test="conditionParamRef.containsKey('customerIdList')">
${_conditionType_} a.customerId in
<foreach collection="conditionParamRef.customerIdList" open="(" close=")" index="index" item="item" separator=",">
#{item}
</foreach>
</if>
<if test="conditionParamRef.containsKey('customerIdStart') and conditionParamRef.customerIdStart != null">
${_conditionType_} a.customerId <![CDATA[ >= ]]> #{${_conditionParam_}.customerIdStart}
</if>
<if test="conditionParamRef.containsKey('customerIdEnd') and conditionParamRef.customerIdEnd != null">
${_conditionType_} a.customerId <![CDATA[ <= ]]> #{${_conditionParam_}.customerIdEnd}
</if>
<if test="conditionParamRef.containsKey('masterplateId')">
<if test="conditionParamRef.masterplateId != null ">
${_conditionType_} a.masterplateId = #{${_conditionParam_}.masterplateId}
</if>
<if test="conditionParamRef.masterplateId == null">
${_conditionType_} a.masterplateId is null
</if>
</if>
<if test="conditionParamRef.containsKey('masterplateIdList')">
${_conditionType_} a.masterplateId in
<foreach collection="conditionParamRef.masterplateIdList" open="(" close=")" index="index" item="item" separator=",">
#{item}
</foreach>
</if>
<if test="conditionParamRef.containsKey('masterplateIdStart') and conditionParamRef.masterplateIdStart != null">
${_conditionType_} a.masterplateId <![CDATA[ >= ]]> #{${_conditionParam_}.masterplateIdStart}
</if>
<if test="conditionParamRef.containsKey('masterplateIdEnd') and conditionParamRef.masterplateIdEnd != null">
${_conditionType_} a.masterplateId <![CDATA[ <= ]]> #{${_conditionParam_}.masterplateIdEnd}
</if>
<if test="conditionParamRef.containsKey('createTime')">
<if test="conditionParamRef.createTime != null ">
${_conditionType_} a.createTime = #{${_conditionParam_}.createTime}
</if>
<if test="conditionParamRef.createTime == null">
${_conditionType_} a.createTime is null
</if>
</if>
<if test="conditionParamRef.containsKey('createTimeStart') and conditionParamRef.createTimeStart != null and conditionParamRef.createTimeStart!=''">
${_conditionType_} a.createTime <![CDATA[ >= ]]> STR_TO_DATE(left(concat(#{${_conditionParam_}.createTimeStart},' 00:00:00'),19),'%Y-%m-%d %k:%i:%s')
</if>
<if test="conditionParamRef.containsKey('createTimeEnd') and conditionParamRef.createTimeEnd != null and conditionParamRef.createTimeEnd!=''">
${_conditionType_} a.createTime <![CDATA[ <= ]]> STR_TO_DATE(left(concat(#{${_conditionParam_}.createTimeEnd},' 23:59:59'),19),'%Y-%m-%d %k:%i:%s')
</if>
</sql>
<sql id="_orderCols_">
<if test="orderColList != null and !orderColList.isEmpty()">
order by
<trim suffixOverrides="," suffix="">
<foreach collection="orderColList" open="" close="" index="index" item="item" separator=",">
${item.colName} ${item.sortKind}
</foreach>
</trim>
</if>
<if test="(orderColList == null or orderColList.isEmpty()) and orderCol != null and !orderCol.isEmpty()">
order by
<trim suffixOverrides="," suffix="">
<if test="orderCol.containsKey('id')">
a.id
<if test='orderCol.id != null and "DESC".equalsIgnoreCase(orderCol.id)'>DESC</if>
,
</if>
<if test="orderCol.containsKey('customerId')">
a.customerId
<if test='orderCol.customerId != null and "DESC".equalsIgnoreCase(orderCol.customerId)'>DESC</if>
,
</if>
<if test="orderCol.containsKey('masterplateId')">
a.masterplateId
<if test='orderCol.masterplateId != null and "DESC".equalsIgnoreCase(orderCol.masterplateId)'>DESC</if>
,
</if>
<if test="orderCol.containsKey('createTime')">
a.createTime
<if test='orderCol.createTime != null and "DESC".equalsIgnoreCase(orderCol.createTime)'>DESC</if>
,
</if>
</trim>
</if>
</sql>
<sql id="_group_by_">
<if test="groupList != null and !groupList.isEmpty()">
GROUP BY
<trim suffixOverrides="," suffix="">
<foreach collection="groupList" open="" close="" index="index" item="item" separator=",">
${item}
</foreach>
</trim>
</if>
</sql>
</mapper>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment